﻿'********************************************************************************
'*
'*      着工/完了履歴　ベースフォーム
'*
'*      File Name : frmStartCompleteBase.vb
'*      Title     : 着工/完了履歴ベース画面
'*      機能    　：着工/完了履歴の基本動作
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.0   2016/07/11 S.Yu         新規作成
' V2.0.0   2017/06/08 T.Yutaro     蘇州対応
' V2.1.0   2017/07/14 S.Yu         固定式BCR対応
' V3.0.0   2017/12/12 安部         外部EXE起動機能追加
' V3.0.1   2018/01/13 佐川         GroupKey対応
' V3.0.2   2018/01/13 安部         GroupKey対応(不良入力関連)
' V3.0.3   2018/01/17 苗           bSite仕掛移動、数量変更後、SF対応できない問題の対応
'********************************************************************************

Imports System.ComponentModel
Imports System.Net.NetworkInformation
Imports System.Text
Imports System.Web.Script.Serialization
Imports ICtagControl.VBStrings
Imports Newtonsoft.Json.Linq

Public Class frmStartCompleteBase

#Region "定数・変数"
    Public Const MULTI_TAG As Boolean = True
    Public Const SINGLE_TAG As Boolean = False
    Public Const BEEP As Boolean = True
    Public Const NO_BEEP As Boolean = False
    '>>20170717
    Public Const CMD_JI As String = "/00000**JIL{0}={1}K{2}I{3}T{4}I{5}:{6}E{7}M{8}K{9}"
    Public Const CMD_JO As String = "/00000**JOL{0}={1}K{2}I{3}T{4}I{5}:{6}Q{7}:{8}K{9}M{10}C{11}W{12}S{13}K{14}S{15}T{16}W{17}K{18}B{19}E{20}"
    Public Const CMD_JC As String = "/00000**JCL{0}={1}K{2}I{3}T{4}I{5}:{6}"
    Public Const CMD_JM As String = "/00000**JML{0}={1}K{2}I{3}S{4}T{5}I{6}:{7}Y{8}:{9}:{10}:{11}:{12}:{13}:{14}"
    Public Const CMD_NI As String = "/00000**NIL{0}={1}I{2}"
    Public Const CMD_NJ As String = "/00000**NJR{3}L{0}={1}I{2}"
    Public Const CMD_NO As String = "/00000**NOL{0}={1}I{2}"
    Public Const CMD_NP As String = "/00000**NPR{3}L{0}={1}I{2}"
    Public Const CMD_NC As String = "/00000**NOL{0}={1}I{2}"
    Public Const CMD_ND As String = "/00000**NPR{3}L{0}={1}I{2}"
    '<<20170717
    Public Const FRM_TITLE As String = "{0}　着工履歴"
    Public Const FRM_HEADER As String = "{0}　着工履歴入力"
    Public Const DATE_TIME_FORMAT As String = "yyyy年MM月dd日　HH時mm分"
    Public Const DATE_TIME_FORMAT_DB As String = "yyyy/MM/dd HH:mm:ss"
    Public Const DATE_TIME_FORMAT_BAKE As String = "yyyy/MM/dd HH:mm"
    Public Const DB_FrameID As String = "RD003"
    Public Const DB_PasteID As String = "RD004"
    Public Const WB_AuWireID As String = "RD010"
    'Protected Const WB_CapillaryID As String = "RD011"
    Public Const Mold_ResinID As String = "RD012"
    Public Const DB_FrameCata As String = "フレーム"
    Public Const DB_PasteCata As String = "Ａｇペースト"
    Public Const WB_AuWireCata As String = "Ａｕ線"
    Public Const Mold_ResinCata As String = "レジン"
    Public ReadOnly NORMAL_INIT_COLOR As Color = Drawing.SystemColors.ButtonHighlight
    Public ReadOnly BUTTON_INIT_COLOR As Color = Drawing.SystemColors.ControlLight
    Public ReadOnly BARCODE_INIT_COLOR As Drawing.Color = Color.Orange
    Public ReadOnly TENKEY_INIT_COLOR As Drawing.Color = Color.Yellow
    Public ReadOnly ERROR_INIT_COLOR As Drawing.Color = Color.Red
    Public ReadOnly FOCUS_INIT_COLOR As Drawing.Color = Color.Cyan
    Public ReadOnly ENTERED_INIT_COLOR As Drawing.Color = Color.GreenYellow
    ' 2017/05/19 蘇州対応 追加
    ' 共通項目グリッド化
    Private Const GRIDVIEW_ROWS As Integer = 9
    Public Const KOMOKU_CELL As Integer = 0            ' グリッド：項目列
    Public Const COND_CELL As Integer = 1              ' グリッド：製造条件列
    Public Const RESULT_CELL As Integer = 2            ' グリッド：現物型式列
    Public Const CHECK_CELL As Integer = 3             ' グリッド：チェック列（不可視）
    Public Const CONDTAG_CELL As Integer = 4           ' グリッド：製造条件TAG列（不可視）
    Public Const GETCONDFLG_CELL As Integer = 5        ' グリッド：製造条件取得元区分列（不可視）
    Public Const KEYPAD_CELL As Integer = 6            ' グリッド：テンキー画面列（不可視）
    Public Const SELWINDOW_CELL As Integer = 7         ' グリッド：選択画面列（不可視）
    Public Const CHECKRESULT_CELL As Integer = 8       ' グリッド：確認結果列（不可視）
    Public Const VIEW As String = "0"                  ' 表示
    Public Const BEGIN As String = "1"                 ' 着工
    Public Const COMPLETE As String = "2"              ' 製造完成
    Public Const TOTAL As String = "3"                 ' 計上完成
    Public Const CANCEL As String = "9"                ' キャンセル     '>>20180323 大賀 No117 ロットキャンセルの履歴保存
    Private Const ACTIVE As String = "1"               ' マスタ＿アクティブフラグ：活性
    Private Const NOT_ACTIVE As String = "0"           ' マスタ＿アクティブフラグ：非活性
    Private Const METHOD_CONFIRM As String = "1"       ' マスタ＿入力方法：確認
    Private Const METHOD_BARCODE As String = "2"       ' マスタ＿入力方法：バーコード
    Private Const METHOD_TENKEY As String = "3"        ' マスタ＿入力方法：テンキー
    Private Const METHOD_SELECT As String = "4"        ' マスタ＿入力方法：選択
    Private Const METHOD_HYOJI As String = "5"         ' マスタ＿入力方法：表示
    Private Const METHOD_ZUKEI As String = "6"         ' マスタ＿入力方法：図形
    Private Const OK_NG As String = "1"                ' マスタ＿起動画面：OK_NG
    Private Const WAFER As String = "2"                ' マスタ＿起動画面：ウエハ径
    Private Const INSP_METHOD As String = "3"          ' マスタ＿起動画面：検査方法
    Private Const ZONE As String = "4"                 ' マスタ＿起動画面：ZONE
    Private Const CHECK_OK As Integer = 1              ' グリッド＿チェック列：OK
    Private Const CHECK_NG As Integer = 0              ' グリッド＿チェック列：NG
    Private Const CHECK_THROUGH As Integer = 2         ' グリッド＿チェック列：チェックなし
    Private Const DB_SEQ_LOT As Integer = 1            ' DB登録時，ロット項目用SEQNO
    Private Const JYOKEN As Integer = 1                ' グリッド＿製造条件取得元区分列：l_jyokendata
    Private Const PREKOTEI As Integer = 2              ' グリッド＿製造条件取得元区分列：前工程
    Private Const TENKEY_INT As String = "1"           ' マスタ＿テンキー：整数
    Private Const TENKEY_DEC As String = "2"           ' マスタ＿テンキー：小数
    Private Const TENKEY_HYPHEN As String = "3"        ' マスタ＿テンキー：ハイフン
    Private Const TYPE_DATE As String = "1"            ' マスタ＿型：日付
    Public Const HYPHEN As String = "-"                ' ハイフン
    Public Const CND_TAG_FLG_JYOKEN As String = "1"    ' 製造条件TAGフラグ：l_jyokendataに登録される製造条件TAG
    Public Const CND_TAG_FLG_ELSE As String = "0"      ' 製造条件TAGフラグ：上記以外
    Public Const CHECKED As String = "1"               ' グリッド＿確認結果列：確認済み
    Public Const NOTCHECKED As String = "2"            ' グリッド＿確認結果列：確認不要
    Public Const NOTCONFIRMED As String = "0"          ' グリッド＿確認結果列：確認済み，確認不要以外
    Public Const KEYPAD_CHECK As String = "_CHECK"     ' テンキーTag判別用
    Public Const KEYPAD_INT As String = "INT"          ' テンキーTag判別（整数）
    Public Const KEYPAD_DEC As String = "DEC"          ' テンキーTag判別（小数）
    Public Const KEYPAD_MW As String = "CHA_MW"        ' テンキーTag判別（MW）
    Public Const KEYPAD_L As String = "CHA_L"          ' テンキーTag判別（L）
    Public Const KEYPAD_SLASH As String = "SLASH"      ' テンキーTag判別（/）
    Public Const GC_KIND_NM As String = "PRODUCT NAME" ' KOMOKUNAME：品名
    Public Const GC_PB_LAYOUT As String = "PB LAYOUT"  ' KOMOKUNAME：PB-LAYOUT図1
    Public Const GC_SHAPE As String = "SHAPE"          ' KOMOKUNAME：製品外形
    Public Const GC_MARK As String = "MARK DETAIL"     ' KOMOKUNAME：MARK DETAIL
    Public Const GC_LOTINFO As String = "LOTINFO"      ' KOTEI：LOTINFO
    Public Const COND_OKNG As String = "OK/NG"         ' 製造条件表示用OK/NG
    Public Const COND_ZONE As String = "ZONE1/ZONE2"   ' 製造条件表示用ZONE
    Public Const KOMOKUNAME As String = "KOMOKUNAME"   ' 条件テーブルの項目名
    Public Const KOMOKUDATA As String = "KOMOKUDATA"   ' 条件テーブルのデータ
    '>>2018/2/13 大賀 サンプル数量対応
    Public Const AGGREGATE_PKG As String = "AGGREGATE PKG" ' 製造条件：集約パッケージ項目名(サンプル数量用)
    '<<2018/2/13 大賀 サンプル数量対応
    Public bsiteRtn As Boolean = False
    '>>20180122 佐川
    Public Const MARK_DATA As String = "MARK"          ' KOMOKUNAME：マーク図値
    Public Const MARK_SIZE As String = "CHAR"          ' KOMOKUNAME：マーク図サイズ
    '<<20180122 佐川

    Public Const GC_WAFER_CASE_NO As String = "WAFER CASE NO"   ' ウェハケースNo
    Public Const GC_RACK_NO As String = "RACK NO"               ' ラックNo
    'ADD 苗 2018/1/5 BEGIN
    Public Const GC_COMP_MS_RACK_NO As String = "COMP MS RACK NO"               ' ラックNo
    'ADD 苗 2018/1/5 END
    Public Const GC_CONS_RACK_NO As String = "CONS RACK NO"     ' 一貫ラックNo
    Public Const BAKE_CLIENT As String = "SF-"                  ' ベーククライアント
    Public Const GC_CHECK_COUNT As String = "CHECK COUNT"       ' 検査数
    Public Const GC_LIMIT_TIME_MINUTE As String = "LIMIT TIME MINUTE"   ' リミットタイム（分）

    Public Const INPUTLOTTYPE_DIFF As String = "0"     ' 拡散
    Public Const INPUTLOTTYPE_ASM As String = "1"      ' 組立

    Public Const DELETE_RACK_NO As String = "9999999999" '削除ラックNo

    ' 着工条件のフラグ管理
    Public Const PASS_SCORE_WAIT_CHECK As Integer = 0       ' 着工条件チェック待ち
    Public Const PASS_SCORE_CHECKED As Integer = 1          ' 着工条件チェック済み

    Public Const MNF_CND_TAG_FLG_REGIST_DB As String = "1"  ' jyokendataに登録されている製造条件TAGの値
    Public Const MNF_CND_TAG_FLG_OTHER As String = "0"      ' 上記でない値

    Public Const DEF_SLASH As String = "/"

    ' 履歴明細の物理名定義
    Public Const DB_WORK_RESULT_PHYSICALNAME_LOT_NO = "LOT_NO"                      ' ロットNo.
    Public Const DB_WORK_RESULT_PHYSICALNAME_KOUTEI_CD = "KOUTEI_CD"                ' 工程コード
    Public Const DB_WORK_RESULT_PHYSICALNAME_TYPE = "TYPE"                          ' 種別
    Public Const DB_WORK_RESULT_PHYSICALNAME_PROC_TIMES = "PROC_TIMES"              ' 処理回数
    Public Const DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG = "MNF_CND_TAG"            ' 製造条件TAG
    Public Const DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG = "MNF_CND_TAG_FLG"    ' 製造条件TAGフラグ
    Public Const DB_WORK_RESULT_PHYSICALNAME_SEQ = "SEQ"                            ' SEQ
    Public Const DB_WORK_RESULT_PHYSICALNAME_MNF_CONDITION = "MNF_CONDITION"        ' 製造条件
    Public Const DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL = "ACTUAL_MODEL"          ' 現物型式
    Public Const DB_WORK_RESULT_PHYSICALNAME_MANAGEMENT_NO = "MANAGEMENT_NO"        ' 管理番号
    Public Const DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT = "MATERIAL_LOT"          ' 材料ロット
    Public Const DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME = "LIMIT_TIME"              ' 使用期限
    Public Const DB_WORK_RESULT_PHYSICALNAME_UPDATE_TIME = "UPDATE_TIME"            ' 更新日時
    Public Const EXEC_PG_TAG_BAD As String = "INPUT_BAD"                            ' FrameIDの不良項目入力画面 ADD 苗 2018/1/26

    '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
    Public Const WRITE_WAFER As Integer = 1             ' l_tag_lotdataのwafer_numに保存する
    Public Const WRITE_FRAME As Integer = 0             ' l_tag_lotdataのiFrameに保存する
    Public Const READ_WAFER As Integer = 1              ' l_tag_lotdataのwafer_numを表示する
    Public Const READ_FRAME As Integer = 0              ' l_tag_lotdataのiFrameを表示する
    Public Const WAFER_NUM_DEFAULT As Integer = -1      ' wafer_numのデフォルト値
    '<<20180302 大賀 GroupKey入力時ウェハ枚数入力

    Public Const SOCKET_FLAG_OFF As String = "0"       ' ファイル通信
    Public Const SOCKET_FLAG_ON As String = "1"        ' ソケット通信

    Private dtGridViewMaster As DataTable              ' LOTタブ項目保持用
    Private dtRowsCount As Integer                     ' LOTタブ項目数
    '    Protected htMsgMst As New Hashtable                ' エラーメッセージ保持
    Protected dtDBUpd As New DataTable                 ' 各工程明細テーブル更新用
    Protected dtJyokenData As New DataTable            ' l_jyokendata保持
    Protected dtDetailData As New DataTable            ' 各工程明細テーブルデータ
    Protected dtPreDetailData As New DataTable         ' 各工程の前工程明細テーブルデータ
    Protected dtHeaderData As New DataTable            ' ヘッダーテーブルデータ保持
    Protected dtFlow As New DataTable                  ' 工程フロー用
    Protected lotCheckFlg As Integer = 0               ' LOTタブ確認項目チェックフラグ
    Protected serverTime As DateTime                   ' 各工程明細テーブル・ヘッダーテーブル更新用サーバー日時
    Protected rackNoCnt As Integer = 0                 ' 前工程ラックNo数
    Protected htRackNo As Hashtable = New Hashtable    ' 前工程ラックNo用
    Protected outHeader As InSiteWebService.OutHeader  ' bSite応答
    Protected outLotInfo As InSiteWebService.LotStdType ' bSite応答
    Protected outWeekCode As String = ""                ' 週コード
    Protected bsiteSuccessFlag As Boolean = False       ' ベークbSite応答フラグ
    Public inputLotType As String = ""                  'ロットタイプ判定フラグ
    Public x_input_flag As Integer
    '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
    Public wf_write_flag As Integer                     ' 共通部フレーム枚数(右側)をl_tag_lotdataのwafer_numに保存するか
    Public wf_read_flag As Integer                      ' 共通部フレーム枚数(左側)にl_tag_lotdataのwafer_numを表示するか
    '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
    '>>20171202 兪
    Public fAutoX As Boolean = True                     '×印数自動入力フラグ
    '<<20171202 兪
    ' 2017/05/19 蘇州対応 追加
    Protected markchart As String = ""                ' MARK CHART内容保持用
    '>>20180122 佐川
    Protected markchartsize As String = ""                ' MARK CHART SIZE内容保持用
    '<<20180122 佐川
    'Private ReadOnly WarningMsg() As String = {
    '    "重点管理不良が発生しました。ABIREXを発行して下さい。",
    '    "Agペースト付着発生。ABIREXを発行して下さい。",
    '    "ネック切れ発生。ABIREXを発行して下さい。",
    '    "入力したロットは全数検査対象の製品です。",
    '    "入力したロットはQR製品です。不良修正システムの入力数確認を忘れないで下さい。",
    '    "入力したロットは同期化対象製品です。",
    '    "不良率が異常値管理基準を超えています。ABIREXを発行して下さい。",
    '    "断線エラーが0.5%以上発生しました。ロットを一時STOPし不良内容を調査して下さい。(指示書№Q1502-054)",
    '    "不良率が異常値管理基準を超えています。ロット保留します。"}

    'Public g_cRFID As clsRfidTag
    Protected m_cIdohyo As New clsDbIdoHyo
    Protected m_cFactoryInfo As New clsDbFactoryInfo
    Protected m_cData As New clsDbCondData
    Protected m_cEquipMat As New clsDbEquipMat
    Protected m_cLotDefect As New clsDbLotDefect
    Protected m_cLotInfo As New clsDbLotInfo
    Protected m_cLog As New clsIcTagLog
    Protected m_cBsiteMess As New clsDbBsiteMess
    'ペーストDB
    Protected m_cPaste As New clsDbPaste
    '金線DB
    Protected m_cWire As New clsDbWire
    'itinfraDB
    Protected m_cItinfra As New clsDbInsitetest
    'レジンDB
    Protected m_cResin As New clsDbResin
    '組立ロット毎不良データ
    Protected m_cLotBadDatat As New clsDBLotBadData
    ' WB画面ラック管理
    Protected m_cWBRackMng As New clsDBWbRackMng
    '>>20180113 佐川
    '不良数DB
    Protected m_cLotBadData As New clsDBLotBadData
    '<<20180113 佐川
    ' >> Add 大賀 2018/2/8 サンプル数量DBアクセスクラスの作成 
    Protected m_cSamplingDef As clsDbSamplingDef
    ' << Add 大賀 2018/2/8 サンプル数量DBアクセスクラスの作成 

    '>> 2017/02/14 佐川 金型連続使用チェック
    Protected m_cDbMold As New clsDbMold
    '<< 2017/02/14 佐川 金型連続使用チェック

    'ADD ラックNo.の桁数チェックフラグ（１：する、０:しない） 苗 2018/1/27
    Protected m_RackWidthCheck As Integer = 1 'UPD 苗 2018/2/28 すべて工程：6桁じゃない場合、エラー

    Protected lblLostframe As Label
    Protected strLostFrame As String

    Protected lblEmptyChipsCnt As Label 'ADD 苗 2018/1/31 空チップ数のラベル

    '×印数格納変数
    Protected inputCrossPcbCnt As Integer = 0
    'cross_frmqty"0"代入変数
    Public Const crossFrmqty0 As String = "0"

    '工程フロー(dgvFlow)bvg b の行
    Protected Const COL_PROC As Integer = 1
    Protected Const COL_PROC_TABLE As Integer = 2

    'ADD チェックの場合：ラックNo.の桁数 苗 2018/1/27
    '>>20180313 大賀 搬送容器桁数チェックを共通化
    'ウェハケースNo.の桁数
    Public Const WAFER_CASE_NO_LENGTH As Integer = 6
    'ラックNo.の桁数
    Public Const RACK_CASE_NO_LENGTH As Integer = 6
    'MSラックNo.の桁数
    Public Const MS_RACK_CASE_NO_LENGTH As Integer = 6
    '<<20180313 大賀 搬送容器桁数チェックを共通化

    'テンキーcheckMatch有効フラグ
    Protected tenkeyChkMatchFlg = True
    Protected common_jo_check As Boolean = True
    '>>20180112 佐川
    '拡散ロットループ回数
    Dim execCount As Double = 0
    '拡散ロットメッセージ格納用
    Dim frmGroupKeyResultMsg
    '>>20180112 佐川
    '>>20180118 佐川
    'changeAtrtibuteSaerVice送信用ラックNo
    Protected changeAttributeRackNo1 As String = ""
    'changeAtrtibuteSaerVice送信用ラックNo
    Protected changeAttributeRackNo2 As String = ""
    'changeAtrtibuteSaerVice送信用工程
    'Private Const PROC_CD_TC As String = "A10"
    'Protected Const PROC_CD_DBA As String = "A41" 'ADD 苗 2018/4/2
    'Protected Const PROC_CD_WBA As String = "A42" 'ADD 苗 2018/4/2
    'Protected Const PROC_CD_WBS As String = "S42" 'ADD 苗 2018/4/2
    'Protected Const PROC_CD_DBS As String = "S41" 'ADD 苗 2020/4/8
    'Protected Const PROC_CD_MOLDS As String = "S51" 'ADD 苗 2020/4/8
    'Protected Const PROC_CD_MOLDA As String = "A51" 'ADD 苗 2020/4/8
    '>>20180118 佐川

    'IC廃棄のフレーム枚数
    Protected m_disposalFrmNum As Integer = 999999

    'ベック一括着工・完工の数量
    Protected m_bakeNum As Integer = 10

    Protected strOptNoEnd As String 'ADD 苗 2018/4/2 完了作業者を格納

    Private strTitle As String 'ADD 苗 2018/4/19 DEL 苗 2018/4/23 ADD 苗 2018/5/8


    Protected rackCount As Integer = 0 'ADD MIAO 2018/9/26 

    Protected LN_FLAG As Boolean = False 'ADD MIAO 2019/10/1
    Protected LH_FLAG As Boolean = False 'ADD MIAO 2019/10/1
    Protected initializForm_FLG As Boolean = True 'ADD MIAO 2019/10/1
    Protected AutoManualMode As Integer = 1 'ADD MIAO 2019/10/1 0:自動モード　1:手動モード
    Protected receiveDataStrList As String() 'ADD MIAO 2019/12/10 
    Protected perReceiveDataStr As String 'ADD MIAO 2019/12/10
    Protected commandSize As Integer 'ADD MIAO 2019/12/10

    Protected MaterialLotList As New List(Of String) 'ADD MIAO 2019/12/10
    Protected MachineNameList As New List(Of String) 'ADD MIAO 2019/12/10
    Protected RandCheckFLAG As Boolean = False 'TRUE抜取検査要
    Protected Const CAR As String = "0"
    Protected Const CIVIL As String = "1"
    Protected Const RC_TYPE As String = "外观检查"
    Protected Const RC_TYPEX As String = "外观检查/X线检查"
    Protected Command_LD_Received As Boolean = True
    Protected KeijyoFlg As Boolean = True
    Protected A_PROC_SKIP As Boolean = True 'True A工程SKIP
    Protected LC_COMMAND As String = "" '2020/07/17
    Protected reconfirmNBIGS As Boolean = False '2020/07/18
    Protected UserNo As String
    Protected LC_SEND_FLG As Boolean = True

    '收到LH后，进行bsite计上，计上结果
    Protected NP_IU_RTN As Boolean = True '2020/08/17 ver.70 
    Protected LN_COLSED As Boolean = True
    Protected WaitLDCommand As receiveCommandData = Nothing  '2020/08/17 ver.70 
    Protected LotProcNonConformityMSG As Boolean = True
    '当LH处理错误，但又收到LN了，这就是临时存放命令的变量
    Protected WaitLnCommand As receiveCommandData = Nothing  '2020/08/17 ver.70 
    'ADD MIAO 2020/09/03 begin Ver.71 
    Protected NPP As New NPParameter

    '当得到LN分析失败后，是否发IT、NJ
    Protected LNNG_MSG_FLG As Boolean = False
    Public Structure NPParameter
        Dim szLotNo As String
        Dim szDifLotNo As String
        Dim ProcessCD As String
        Dim EQUIP_ID As String
        Dim EQUIP_No As String
        Dim OptNoEnd As String
        Dim kindNm As String
        Dim Shape As String
        Dim PbLayout As String
    End Structure
    'ADD MIAO 2020/09/03 begin Ver.71 
    '画面状態
    Public Enum ProcessStatus
        Ready
        TagSet
        Preprocess
        Processing
        ManufComplete
        TotalComplete
        Canceled
        Failed
        Hold
        TempProcessing '臨時着工　ADD 苗 2018/1/6
        TempComplete '臨時完成　ADD 苗 2018/1/6
    End Enum

    'ICタグ読取状態
    Protected Enum TagStatus
        Non
        TagSet
        All
        Check1
        Check2
        Remove
        'Done
    End Enum

    'ICタグ着工状態
    Public Enum TagProcessStatus
        Ready
        Processing
        ManufComplete
    End Enum
    '>>20180329 大賀 No125 S42で最後の完成を実施しても臨時完成となる場合がある
    Public Const WB_BSITE_SENDING = "9"      ' WB工程で複数端末でのステータス管理用

    'WBbSite通信状態
    Public Enum SendStatus
        OK
        NG
        SENDING
    End Enum
    '<<20180329 大賀 No125 S42で最後の完成を実施しても臨時完成となる場合がある

    '完了種類区分
    Protected Enum CompleteType
        ManufComplete
        TotalComplete
        All
    End Enum

    '長押しタイマー動作選択
    Protected Enum DelayType
        Tenkey
        Qflag
        Confirm
        InputDone
    End Enum

    'コマンド選択
    Protected Enum CommandType
        JI
        JO
        JC
        JM
    End Enum

    '不良率判定結果
    Protected Enum DefectJudgement
        OK
        WARNING
        HOLD
        ERR
    End Enum

    '保留対応区分
    Public Enum OnHoldStatus
        Normal
        OnHold
        Solved
    End Enum

    'ICタグ中身
    Public Structure TagData
        Dim szUID As String
        Dim szLotNo As String
        Dim szDifLotNo As String
        Dim Status As TagProcessStatus
        Dim szEquipID As String
        Dim szProcsCD As String
        Dim iInput As Integer
        Dim iFinish As Integer
        Dim iFailed As Integer
        Dim iFrame As Integer
        Dim iCross As Integer
        Dim iCrossFrm As Integer
        Dim fQflag As Boolean
        Dim fTestflag As Boolean
        Dim fCheckflag As Boolean
        Dim OnHoldSt As OnHoldStatus
        Dim iDisposalFrmNum As Integer 'ADD 2018/1/24 苗
        Dim iFrameIDUse As Integer 'ADD 苗 2018/1/26 フレームID対応
        '>>2018/1/30 佐川 キャリア交換対応
        Dim container1 As String
        Dim container2 As String
        Dim container5 As String
        Dim container3 As String
        Dim container4 As String
        '<<2018/1/30 佐川 キャリア交換対応
        '>>2018/2/13 大賀 サンプル数量対応
        Dim plateEquipNo As String
        '>>2018/2/13 大賀 サンプル数量対応
        '>>2018/2/16 大賀 No74 ICタグ編集項目追加対応
        Dim emptyChipNum As Integer
        Dim frameIDFlag As Boolean
        '<<2018/2/16 大賀 No74 ICタグ編集項目追加対応
        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
        Dim waferNum As Integer
        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力

        '>>2018/2/27 大賀 IcTagデータ設定共通化
        ' 初期値設定コンストラクタ
        Sub New(init As Boolean)
            szUID = String.Empty
            szLotNo = String.Empty      '組立Lot No
            szDifLotNo = String.Empty   '拡散Lot No
            Status = Integer.MinValue   '状態
            szEquipID = String.Empty    '装置No
            szProcsCD = String.Empty    '工程コード
            iInput = Integer.MinValue   '投入数
            iFinish = Integer.MinValue  '完成数
            iFailed = Integer.MinValue  '不良数
            iFrame = Integer.MinValue   'フレーム数
            iCross = Integer.MinValue   '×印数
            iCrossFrm = Integer.MinValue '×印枚数
            iFrameIDUse = Integer.MinValue     'フレームIDフラグ
            iDisposalFrmNum = Integer.MinValue '廃棄フレーム枚数
            fQflag = Boolean.TrueString     'Qフラグ
            fTestflag = Boolean.TrueString  'TESTフラグ
            fCheckflag = Boolean.TrueString 'CHECKフラグ
            frameIDFlag = Boolean.TrueString 'フレームIDフラグ
            OnHoldSt = Integer.MinValue     '保留フラグ
            container1 = String.Empty   'ラックケース1
            container2 = String.Empty   'ラックケース2
            container3 = String.Empty   'ラックケース3
            container4 = String.Empty   'ラックケース4
            container5 = String.Empty   'ラックケース5
            plateEquipNo = String.Empty   'メッキ工程装置No
            emptyChipNum = Integer.MinValue '空チップ数
            waferNum = Integer.MinValue 'ウェハ枚数
        End Sub

        ' l_tag_lotdataからの読出しデータを設定する
        Sub setData(dtData As DataTable)
            With dtData
                ''UID
                szUID = frmStartCompleteBase.BytesToHexString({&HFE, &HD, &H45,
                           &H50, &H1, &H4, &HE0, &H42})
                '組立Lot No
                szLotNo = DBNullTOblank(.Rows(0)("lot_no")) 'UPD 苗 2018/10/23
                '拡散Lot No
                szDifLotNo = DBNullTOblank(.Rows(0)("wafer_lotno")) 'UPD 苗 2018/10/23
                '状態
                Status = DBNullTOblank(.Rows(0)("status")) 'UPD 苗 2018/10/23
                '装置No
                szEquipID = DBNullTOblank(.Rows(0)("equipno")) 'UPD 苗 2018/10/23
                '工程コード
                szProcsCD = DBNullTOblank(.Rows(0)("koutei_code")) 'UPD 苗 2018/10/23
                '投入数
                iInput = DBNullTOblank(.Rows(0)("invNum")) 'UPD 苗 2018/10/23
                '完成数
                iFinish = DBNullTOblank(.Rows(0)("compNum")) 'UPD 苗 2018/10/23
                '不良数
                iFailed = DBNullTOblank(.Rows(0)("badNum")) 'UPD 苗 2018/10/23
                'フレーム数
                iFrame = DBNullTOblank(.Rows(0)("frameNum")) 'UPD 苗 2018/10/23
                '×印数
                iCross = DBNullTOblank(.Rows(0)("BADMARKNUM")) 'UPD 苗 2018/10/23
                '×印枚数
                iCrossFrm = DBNullTOblank(.Rows(0)("badmark_framenum")) 'UPD 苗 2018/10/23
                'Qフラグ
                fQflag = If(.Rows(0)("q_flg") = 1, True, False)
                'TESTフラグ
                fTestflag = If(.Rows(0)("test_flg") = 1, True, False)
                'CHECKフラグ
                fCheckflag = If(.Rows(0)("check_flg") = 1, True, False)
                'HOLDフラグ
                OnHoldSt = DBNullTOblank(.Rows(0)("holdStatus"))
                'CASE1～5
                container1 = DBNullTOblank(.Rows(0)("container1"))
                container2 = DBNullTOblank(.Rows(0)("container2"))
                container3 = DBNullTOblank(.Rows(0)("container3"))
                container4 = DBNullTOblank(.Rows(0)("container4"))
                container5 = DBNullTOblank(.Rows(0)("container5"))
                'フレーム管理フラグ
                iFrameIDUse = .Rows(0)("frame_ID_use")
                frameIDFlag = If(iFrameIDUse = 1, True, False)
                'PLT設備
                plateEquipNo = DBNullTOblank(.Rows(0)("plt_equipno")）
                '空チップ数
                emptyChipNum = .Rows(0)("empty_chip_num")
                'IC廃棄のフレーム枚数
                iDisposalFrmNum = .Rows(0)("disposal_frame_num")
                'ウェハ枚数
                waferNum = .Rows(0)("wafer_num")
            End With
        End Sub
        Function DBNullTOblank(obj As Object) As String
            DBNullTOblank = IIf(IsDBNull(obj), "", obj)
        End Function
        ''' <summary>
        ''' 初期値設定
        ''' </summary>
        Public Shared ReadOnly Initalize As TagData = New TagData(True)
        '<<2018/2/27 大賀 IcTagデータ設定共通化
    End Structure

    'Log
    Public Structure Log
        Dim szEquipID As String
        Dim szProcCD As String
        Dim szLotNo As String
        Dim dteOpt As DateTime
        Dim szOperator As String
        Dim szControl As String
        Dim szMsg As String
    End Structure

    Protected IcTag As New TagData
    Protected LastTag As New TagData
    Protected LastWriteTag As New TagData
    '>>20180111 兪
    Protected GroupID() As TagData
    '<<20180111 兪
    Protected dtError As New DataTable
    Protected m_dtMat As New DataTable
    Protected m_dtHeader As New DataTable
    Protected dtData As New DataTable
    Protected m_szLastLot As String = String.Empty
    Protected m_ProcessStatus As ProcessStatus
    Protected m_PerProcessStatus As ProcessStatus 'エラー前の状態 ADD 苗 2018/1/26
    Protected m_TagStatus As TagStatus
    Protected m_CompleteType As CompleteType
    Protected m_DelayType As DelayType
    Protected m_CmdType As CommandType
    '>> 2018/02/20 安部 iniファイル整理
    'Protected m_fIcTagUsed As Boolean
    'Protected m_szPortName As String
    '<< 2018/02/20 安部 iniファイル整理
    Protected PASS_SCORE As Integer
    Protected m_iScore As Integer()
    Protected m_fColl As Boolean = False
    Protected m_fWaited As Boolean = False
    Protected m_iTimerCnt As Integer = 0
    Protected m_iTimeOutCnt As Integer
    Protected m_iTimeOut As Integer
    Protected m_szIP As String
    Protected m_iCheck As Integer = 0
    Protected m_iSelfCheck As Integer = 0
    Protected m_iTrialCheck As Integer = 0
    Protected m_iSideCheck As Integer = 0
    Protected m_iChgFrame As Integer = 0
    Protected m_iChgBall As Integer = 0
    Protected m_szCheck As String = String.Empty
    Protected m_szSelfCheck As String = String.Empty
    Protected m_szTrialCheck As String = String.Empty
    Protected m_szSideCheck As String = String.Empty
    Protected m_szChgFrame As String = String.Empty
    Protected m_szChgBall As String = String.Empty
    Protected m_szWeekCD As String = String.Empty
    Protected m_szMemo1 As String = String.Empty
    Protected m_szMemo2 As String = String.Empty
    Protected m_szMatID As String = String.Empty
    Protected m_szMatCata As String = String.Empty
    Protected m_szMakerLot As String = String.Empty
    Protected m_szMatType As String = String.Empty
    Protected m_szMatLot As String = String.Empty
    Protected m_szMatLT As String = String.Empty
    Protected m_iLastFailCnt As Integer = 0
    Protected m_iLastCrossCnt As Integer = 0
    Protected m_dteLimitTimeBase As DateTime
    Protected m_fTestFlg As Boolean = False
    Protected m_IsHolding As OnHoldStatus = OnHoldStatus.Normal
    Protected m_fProcessCheck As Boolean = True
    Protected m_szTable As String = "L_EQUIP_MAT"
    Protected m_szProc As String = ""
    Protected m_szPreProcLotType As String = ""
    Protected m_fTagWriteFailed As Boolean = False
    Protected m_fTagDataRecived As Boolean = False
    'Protected m_fIsResponseOK As Boolean = False
    Protected m_fIsGettingData As Boolean = False
    'Protected m_szLogUser As String = ""
    Protected m_szResult As String = ""
    Protected m_szRange As String = ""
    ' 2017/05/19 蘇州対応 追加
    '>> 2018/02/20 安部 iniファイル整理
    'Protected m_szLang As String = "" ' frmStartCompleteBaseからmodGlobalData へ移動
    'Protected m_szImagePath As String = ""
    '<< 2018/02/20 安部 iniファイル整理
    Protected lotNo As String = ""
    Protected prelotNo As String = ""
    Protected nextProcCode As String = ""
    ' 2017/05/19 蘇州対応 追加
    Protected m_szFrameid_comp As Integer 'ADD 苗 2018/1/26  フレームID対応
    '>>20171109 兪
    '一貫機情報
    Protected m_fIsLineEquip As Boolean = False
    Protected m_szEndProcCD As String = ""

    '>>20171109 兪

    Public Property ErrorTable As DataTable
        Set(ByVal value As DataTable)
            dtError = value
        End Set
        Get
            ErrorTable = dtError
        End Get
    End Property

    Public WriteOnly Property ErrorCount As Integer
        Set(ByVal value As Integer)
            lblFailedCnt.Text = value.ToString
        End Set
    End Property

    Public ReadOnly Property IcTagWriting As Integer
        Get
            IcTagWriting = m_fTagWriteFailed
        End Get
    End Property
#End Region

#Region "画面ロード・アンロード"
    '******************************************************************************
    '*  フォームロード処理
    '******************************************************************************
    Protected Sub frmStartCompleteBase_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If DesignMode = False Then
            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False 'ADD miaojf 2020/08/08 ver.57
            lblVer.Text = My.Application.Info.Version.ToString 'ADD miaojf 2020/08/08 ver.57
            Call AutoCtlSize(Me) 'ADD 苗 2018/1/31
            'UPD 苗 2018/3/1 BEGIN
            Dim DeskTopSize As Size = System.Windows.Forms.SystemInformation.PrimaryMonitorSize
            If DeskTopSize.Width <> 1024 Then
                '表示ｻｲｽﾞをﾚｼﾞｽﾄﾘから取得　　' この数値は要確認：.NETではpixel
                Me.Top = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Top", CStr(0)))
                Me.Left = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Left", CStr(0)))
            Else
                'UPD 苗 2018/3/7 BEGIN
                'Me.StartPosition = FormStartPosition.CenterScreen
                Me.Top = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Top", CStr(100)))
                Me.Left = CInt(GetSetting(My.Application.Info.AssemblyName, Me.Name, "Left", CStr(0)))
                'UPD 苗 2018/3/7 END
            End If
            'UPD 苗 2018/3/1 END
            'Dim szSeries = GetIniFile("SERIAL", "IcTagUsed", "False", g_szInitFileName)

            '>> 2018/02/20 安部 iniファイル整理
            'm_fIcTagUsed = CBool(GetIniFile("SERIAL", "IcTagUsed", "False", g_szInitFileName))
            'm_szPortName = GetIniFile("SERIAL", "PortName", "COM10", g_szInitFileName)

            'コマンド受信pollingタイマー
            'm_CompleteType = CInt(GetIniFile("StartComplete", "CompleteType", "0", g_szInitFileName))
            'm_iTimeOut = Convert.ToInt32(GetIniFile("StartComplete", "TimeOut", 60.ToString, g_szInitFileName))
            m_iTimeOut = g_DBSFCommon.GetFactoryInfo_Num1(PARAM_TIMEOUT, PARAM_TIMEOUT_DEFAULT)
            'Dim iInterval As Integer = Convert.ToInt32(GetIniFile("StartComplete", "TimerInt", 1.ToString, g_szInitFileName))
            Dim iInterval As Integer = g_DBSFCommon.GetFactoryInfo_Num1(PARAM_TIMERINT, PARAM_TIMEOUT_DEFAULT)
            '<< 2018/02/20 安部 iniファイル整理
            m_iTimeOutCnt = CInt(Int(m_iTimeOut / iInterval))
            intTimer.Interval = iInterval * 1000
            ' 2017/05/19 蘇州対応 追加
            '>> 2018/02/20 安部 iniファイル整理
            'm_szLang = GetIniFile("Envm", "LANG", "J", g_szInitFileName)
            'm_szImagePath = GetIniFile("Envm", "ImagePath", "C\", g_szInitFileName)
            '<< 2018/02/20 安部 iniファイル整理
            ' 2017/05/19 蘇州対応 追加

            '>>20171109 兪
            '一貫機情報
            m_fIsLineEquip = CBool(GetIniFile("LineMachine", "IsLineEquip", "False", g_szInitFileName))
            m_szEndProcCD = GetIniFile("LineMachine", "EndProcCD", "", g_szInitFileName)
            '<<20171109 兪

            m_szIP = GetIPAddr()

            m_cIdohyo.GetEquipInfoByID(g_CURRENT_EQUIP_ID)
            g_EQUIP_NO = m_cIdohyo.EquipInfo.szEquipNo
            lblEquipID.Text = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
            'フォントサイズ自動変更
            If g_CURRENT_EQUIP_ID.Length > 9 Then
                Dim eqpFont As Font
                For i As Integer = 12 To 1 Step -1
                    eqpFont = New Font(lblEquipID.Font.FontFamily, i, lblEquipID.Font.Style)
                    If TextRenderer.MeasureText(g_CURRENT_EQUIP_ID, eqpFont).Width <=
                    lblEquipID.Width - lblEquipID.Margin.Left - lblEquipID.Margin.Right Then
                        lblEquipID.Font = eqpFont
                        Exit For
                    End If
                Next
            End If


            lblProcessCD.Text = m_cIdohyo.EquipInfo.szKouteiCD

            'ADD MIAOJF 20200408
            SetProcNo(lblProcessCD.Text)

            lblProcessCD.Tag = m_cIdohyo.EquipInfo.szKouteiCD

            ' >> Add 大賀 2018/2/8 サンプル数量DBアクセスクラスの作成 
            m_cSamplingDef = New clsDbSamplingDef(m_szLang)
            ' << Add 大賀 2018/2/8 サンプル数量DBアクセスクラスの作成 

            'setAllErrMsg(m_szLang)
            SetTitle()
            ' >> Add 安部 2018/2/4 
            If x_input_flag = 0 Then
                'lblPcbCnt.Enabled = False
                lblCrossCnt.Enabled = False
                lblCrossPcbCnt.Enabled = False
            Else
                'lblPcbCnt.Enabled = True
                lblCrossCnt.Enabled = True
                lblCrossPcbCnt.Enabled = True
            End If
            ' << Add 安部 2018/2/4 
            SetPassScore()

            If m_fIcTagUsed Then
                Try
                    '>>20171010 兪
                    If IsNothing(g_cRFID) Then
                        g_cRFID = New clsRfidTag()
                    End If
                    '<<20171010 兪
                    g_cRFID.BeginSerial(m_szPortName, AddressOf RecieveData)
                    g_cRFID.AddSerialEventHandler(AddressOf DataReceive)
                    'g_cRFID.SetMod(clsRfidTag.Mode.RDLOOP, MULTI_TAG, BEEP)
                    TimerTag.Start()
                Catch ex As Exception
                    PutLog(sender.ToString, "", ex.Message)
                    g_cRFID = Nothing
                    'Me.Close()
                    m_fIcTagUsed = False
                    'Exit Sub
                End Try

                m_TagStatus = TagStatus.Non
            End If

            ' 2017/05/12 蘇州対応 追加
            'btnLot_Enable() 'DEL 苗 2018/2/3
            setGridView()
            'タブの設定

            setTabControl()
            selectTab()
            addColumnsDataTable()
            ' 2017/05/12 蘇州対応 追加
            SetHandler()
            InitTenKey()
            InitTenKey_Grid()

            'ラック流動有効設定
            If isStatusCheck() Then
                setRackFlowFlag()
            Else
                If IsNothing(m_cEquipCommandControl) = True Then
                    SetRackFlowEnable()
                End If
            End If


            AddHandler txtLotNo.GotFocus, AddressOf txtBoxGotFocus
            AddHandler txtLotNo.LostFocus, AddressOf txtBoxLostFocus
            AddHandler txtDiffLot.GotFocus, AddressOf txtBoxGotFocus
            AddHandler txtDiffLot.LostFocus, AddressOf txtBoxLostFocus
            AddHandler txtOptNoStt.GotFocus, AddressOf txtBoxGotFocus
            AddHandler txtOptNoStt.LostFocus, AddressOf txtBoxLostFocus
            AddHandler txtOptNoEnd.GotFocus, AddressOf txtBoxGotFocus
            AddHandler txtOptNoEnd.LostFocus, AddressOf txtBoxLostFocus

            PutLog(Me.ToString, String.Empty, "画面開き")
            '--判断设备的Series属性
            Dim EquipSeries = m_cEquipMat.getSeries(lblEquipID.Text)

            If EquipSeries.ToUpper = "M-TEX" Then
                MPflg = "M"
            End If

            '>>20171010 兪
            '>>2018/02/20 安部 swapTimer削除
            'swapTimer.Start()
            'CheckSwapStatus()
            '<<2018/02/20 安部 swapTimer削除
            '<<20171010 兪
            btnLot_Enable() 'ADD 苗 2018/2/3

                chkUserEndTime() 'ADD MIAO 2019/10/1
                Time_LoginUser.Enabled = True
                'If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then
                '    SetFocus()
                'End If
                setProcessingLot()
            End If
    End Sub
    Overridable Sub SetFocus()
    End Sub
    Overridable Sub setProcessingLot()
        Dim InProcLot As String

        InProcLot = getProcessingLot()
        If InProcLot <> "" Then
            txtLotNo.Text = InProcLot
            txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
        End If
    End Sub
    Overridable Sub SetProcNo(ByRef procNo As String)
    End Sub
    Protected Sub chkUserEndTime()
        'ADD MIAO 2019/10/1 BEGIN
        Dim clsUserLogin As New clsLoginUser
        '現在時刻＞ユーザ停止使用時刻の場合、メッセージを表示し、ユーザ変更画面を呼び出し
        If m_cData.GetServerTime > clsUserLogin.getEndTime(g_CURRENT_EQUIP_ID) Then
            If pnlUserLogin.Visible = True Then Exit Sub
            If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Processing Then
                txtOptNoEnd.Text = ""
            End If
            If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Ready Then
                txtOptNoEnd.Text = ""
                txtOptNoStt.Text = ""
            End If
            'MsgBox(getMsgStr("MSG10052"))
            Time_LoginUser.Stop()
            'Dim frmUserLogin As New FrmUserLogin
            'frmUserLogin.ShowDialog()
            'Time_LoginUser.Start()

            pnlUserLogin.Visible = True
            Me.pnlUserLogin.BringToFront()
            txtUser.Select()
            Exit Sub
        End If
        UserNo = clsUserLogin.getUserNo(g_CURRENT_EQUIP_ID)
        If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Processing Then
            If UserNo <> txtOptNoEnd.Text Then
                txtOptNoEnd.Text = UserNo
                Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
                txtOptNoEnd_KeyPress(txtOptNoStt, a)
            End If
        End If
        If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Ready Then
            If UserNo <> txtOptNoStt.Text Then
                txtOptNoEnd.Text = UserNo
                txtOptNoStt.Text = txtOptNoEnd.Text
                Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
                txtOptNoStt_KeyPress(txtOptNoStt, a)
            End If
        End If
        'ADD MIAO 2019/10/1 END

    End Sub

    '画面タイトルの設定
    Overridable Sub SetTitle()

        Dim dt As DataTable = m_cEquipMat.GetTitle(lblProcessCD.Text)
        If dt.Rows.Count <> 0 Then
            Dim szTitle = dt.Rows(0)("PROC_NAME")
            'Me.Text = getMsgStr("MSG00116", szTitle) & "    " & My.Application.Info.Version.ToString 'ADD 苗 2018/2/3
            Me.Text = lblEquipID.Text & " " & 'ADD 苗 2018/4/19
                getMsgStr("MSG00116", szTitle) & "    " & My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Build '2018/2/20 バージョン情報フォーマット変更
            strTitle = Me.Text 'ADD 苗 2018/4/19　DEL 苗 2018/4/23　ADD 苗 2018/5/8
            Label1.Text = getMsgStr("MSG00117", szTitle)

            m_szProc = dt.Rows(0)("PROC_CD")
            m_szTable = dt.Rows(0)("PROC_TABLE")
            m_szPreProcLotType = dt.Rows(0)("PREPROC_LOTTYPE")
            '>>20171202 兪
            fAutoX = CBool(dt.Rows(0)("AUTO_X"))
            '<<20171202 兪

            'ADD 苗 2018/1/26 BEGIN フレームID対応
            m_szFrameid_comp = dt.Rows(0)("frameid_comp")
            'ADD 苗 2018/1/26 END フレームID対応

            inputLotType = dt.Rows(0)("InputLotType") 'ADD 苗 2018/2/1
            x_input_flag = dt.Rows(0)("x_input_flag") 'ADD 安部 2018/2/4
            g_inspection_qty_type = dt.Rows(0)("inspection_qty_type") 'ADD 安部 2018/2/19
            m_CompleteType = dt.Rows(0)("CompleteType") 'ADD 安部 2018/2/20
            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
            wf_write_flag = dt.Rows(0)("wf_write_flag")
            wf_read_flag = dt.Rows(0)("wf_read_flag")
            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
        End If
    End Sub
    ''' <summary>
    ''' ラック流動のフラグを設定する
    ''' </summary>
    Protected Overridable Sub setRackFlowFlag()

    End Sub
    '画面タブの設定
    Overridable Sub setTabControl()

    End Sub

    Overridable Sub selectTab()
        If TabPageLot.Enabled Then
            tabBase.SelectedIndex = 0
        ElseIf TabPageEqp.Enabled Then
            tabBase.SelectedIndex = 1
        Else
            tabBase.SelectedIndex = 2
        End If

        Me.UpdateStyles() 'ADD 苗 2018/2/3
    End Sub

    'タブセレクト
    Private Sub TabControl_Selecting(ByVal sender As Object, ByVal e As TabControlCancelEventArgs) Handles tabBase.Selecting

        If tabBase.SelectedIndex = 0 AndAlso Not TabPageLot.Enabled Then
            e.Cancel = True
        ElseIf tabBase.SelectedIndex = 1 AndAlso Not TabPageEqp.Enabled Then
            e.Cancel = True
        ElseIf tabBase.SelectedIndex = 2 AndAlso Not TabPageSp.Enabled Then
            e.Cancel = True
        Else
            GetControlItem(Me, sender)
            PanelTenKey.Visible = False
            PanelTenKey_Grid.Visible = False
        End If
    End Sub

    Private Sub btnLot_Enable()
        ' inputLotType = GetIniFile("StartComplete", "InputLotType", INPUTLOTTYPE_DIFF, g_szInitFileName) 'DEL 苗 2018/2/1
        txtLotNo.Enabled = False
        txtDiffLot.Enabled = False
        Select Case inputLotType
            Case INPUTLOTTYPE_DIFF
                btnLotTxt.Enabled = False
                txtLotNo.Visible = False
                txtDiffLot.Enabled = True
                txtDiffLot.Focus()
            Case INPUTLOTTYPE_ASM
                btnDiffLot.Enabled = False
                txtDiffLot.Visible = False
                txtLotNo.Enabled = True
                txtLotNo.Focus()
            Case Else
                btnLotTxt.Enabled = False
                btnDiffLot.Enabled = False
                txtLotNo.Visible = False
                txtDiffLot.Visible = False
                lblkindNm.Enabled = False
                lblBeginTime.Enabled = False
                lblEndTime.Enabled = False
                txtLotNo.Enabled = False
                txtLotNo.BackColor = NORMAL_INIT_COLOR
                txtDiffLot.BackColor = NORMAL_INIT_COLOR
                lblDiffLotNo.Enabled = False
                lblPbLayout.Enabled = False
                lblShape.Enabled = False
                lblInputCnt.Enabled = False
                lblInputFrm.Enabled = False
                lblInputCross.Enabled = False
                lblInputCrossFrm.Enabled = False
                lblCompleteCnt.Enabled = False
                lblFailedCnt.Enabled = False
                btnTag.Enabled = False
                lblPcbCnt.Enabled = False
                lblPcbCnt.DefaultColor = NORMAL_INIT_COLOR
                lblCrossCnt.Enabled = False
                lblCrossCnt.DefaultColor = NORMAL_INIT_COLOR
                lblCrossPcbCnt.Enabled = False
                lblCrossPcbCnt.DefaultColor = NORMAL_INIT_COLOR
                btnChecked.Enabled = False
                btnQflag.Enabled = False
                lblQflag.Enabled = False
                lblNextProcs.Enabled = False
                dgvFlow.Enabled = False
                dgvError.Enabled = False
                btnManufComp.Enabled = False
                btnTotalComp.Enabled = False
                btnErrInput.Enabled = False
                btnCancel.Enabled = False
        End Select
    End Sub

    '******************************************************************************
    '*  フォームアンロード処理
    '******************************************************************************
    Protected Sub frmDbHistory_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If IsNothing(m_cEquipCommandControl) = False Then m_cEquipCommandControl.CommandDisConnect()

        If m_fWaited Then
            Exit Sub
        End If

        '>>20171109 兪
        TimerTag.Stop()
        '>>20170714
        'PutIniFile("SERIAL", "IcTagUsed", m_fIcTagUsed.ToString, g_szInitFileName)
        '<<20170714
        'PutIniFile("SERIAL", "PortName", m_szPortName, g_szInitFileName)
        'PutIniFile("StartComplete", "CompleteType", CInt(m_CompleteType), g_szInitFileName)
        'PutIniFile("StartComplete", "TimerInt", (intTimer.Interval / 1000).ToString, g_szInitFileName)
        'PutIniFile("StartComplete", "TimeOut", m_iTimeOut.ToString, g_szInitFileName)

        '一貫機情報
        'PutIniFile("LineMachine", "IsLineEquip", m_fIsLineEquip.ToString, g_szInitFileName)
        'PutIniFile("LineMachine", "EndProcCD", m_szEndProcCD, g_szInitFileName)
        '<<20171109 兪

        '>>20170714
        If IsNothing(g_cRFID) Then
            Exit Sub
        End If
        '<<20170714

        PutLog(Me.ToString, String.Empty, "画面終了")

        '表示ｻｲｽﾞをﾚｼﾞｽﾄﾘに保存
        If Me.WindowState <> FormWindowState.Minimized Then
            SaveSetting(My.Application.Info.AssemblyName, Me.Name, "Top", CStr(Me.Top))
            SaveSetting(My.Application.Info.AssemblyName, Me.Name, "Left", CStr(Me.Left))
        End If

        m_fWaited = False
        '>>20170714
        If m_fIcTagUsed AndAlso Not IsNothing(g_cRFID) Then
            g_cRFID.ClearData()
            g_cRFID.DisableHandShake()
            Me.Cursor = Cursors.WaitCursor
            TimerWait.Start()
            e.Cancel = True
        End If
        '<<20170714
    End Sub

    Protected Sub TimerWait_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerWait.Tick
        m_fWaited = True
        '>>20170714
        g_cRFID.Disconnect()
        TimerWait.Stop()
        g_cRFID.EndSerial()
        '<<20170714
        Me.Close()
        frmInital.Activate()
    End Sub

    'IPアドレスの取得
    Protected Function GetIPAddr() As String
        ' アダプタリストを取得する
        Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
        GetIPAddr = String.Empty
        For Each adapter As NetworkInterface In adapters

            ' ネットワーク接続状態が UP のアダプタのみ表示 
            If (adapter.OperationalStatus = OperationalStatus.Up) Then

                Dim ip_prop As IPInterfaceProperties = adapter.GetIPProperties()

                ' ユニキャスト IPv4 アドレスの取得
                For Each addr As IPAddressInformation In ip_prop.UnicastAddresses()
                    If addr.Address.IsIPv6LinkLocal OrElse
                       addr.Address.IsIPv6Multicast OrElse
                       addr.Address.IsIPv6SiteLocal OrElse
                       addr.Address.IsIPv6Teredo Then
                        Continue For
                    End If

                    If addr.Address.ToString.Length > 16 Then
                        Continue For
                    End If

                    GetIPAddr = addr.Address.ToString
                    Exit Function
                Next

            End If
        Next

        If GetIPAddr.Length <= 0 Then
            MsgBox(getMsgStr("MSG00066"))
        End If
    End Function

    Overridable Sub SetHandler()

    End Sub

    Overridable Sub SetPassScore()

    End Sub

#End Region

#Region "コントロール"

#Region "画面ボタン"
    '******************************************************************************
    '*  「製造完成」クリック処理
    '******************************************************************************
    Protected Sub btnManufComp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnManufComp.Click
        Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " In")

        If txtOptNoEnd.TextLength <= 0 Then
            If AutoManualMode = 0 Then
                txtOptNoEnd.Text = txtOptNoStt.Text
            Else
                MsgBox(getMsgStr("MSG00067"))
                txtOptNoEnd.Focus() ' 20180301 大賀 終了作業者にフォーカスを合わす
                Exit Sub
            End If

        End If
        'ADD 苗 2018/1/5 BEGIN
        If chkCrossFrame() = False Then
            Exit Sub
        End If
        'ADD 苗 2018/1/5 END
        ' 完成時チェック
        If Not ManufCompCheck() Then
            Exit Sub
        End If

        PutLog(sender.ToString, txtOptNoEnd.Text, "ボタンクリック")
        Me.Enabled = False

        '<<20180111 兪
        '>> 20180205 大賀 1つの場合にlotNoが更新されない。計上完成ボタンの判定処理と同じに修正
        ' If GroupID.Length > 1 Then
        If inputLotType = INPUTLOTTYPE_DIFF Then
            '<< 20180205 大賀
            '>> 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            For Each tagData In GroupID.Select(Function(item, i) New With {item, i})
                IcTag = tagData.item
                lotNo = tagData.item.szLotNo
                ManufComplete(tagData.item)
                GroupID(tagData.i) = IcTag
            Next
            '<< 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            IcTag = GroupID(0)
            lotNo = IcTag.szLotNo
        Else
            ManufComplete()
        End If
        '<<20180111 兪

        'PutLog(sender.ToString, txtOptNoEnd.Text, "製造完成")b
        Me.Enabled = True

        If m_ProcessStatus = ProcessStatus.Processing Then
            m_ProcessStatus = ProcessStatus.ManufComplete

            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If

    End Sub

    '>>20180111 兪
    Private Sub ManufComplete(Optional ByVal tagData As TagData = Nothing)
        Dim sender As Object = btnManufComp
        '>>20180328 大賀 No122 DBサーバ時刻を使用する
        'serverTime = Now()
        serverTime = m_cData.GetServerTime()
        '<<20180328 大賀 No122 DBサーバ時刻を使用する
        If Not IsNothing(tagData.szLotNo) Then 'UPD 苗 2018/1/24 tagDataの値が無くても、Nothingではない
            UpdateHeader(ProcessStatus.ManufComplete, serverTime.ToString(DATE_TIME_FORMAT_DB), tagData)
        Else
            UpdateHeader(ProcessStatus.ManufComplete, serverTime.ToString(DATE_TIME_FORMAT_DB))
        End If

        '完成情報の表示と保存
        Dim cnt = SaveCompleteInfo()
        If cnt < 0 Then
            If cnt = -10 Then
                PutLog(sender.ToString, txtOptNoEnd.Text, "更新できる着工記録がありません。")
                DbFailedProcess(getMsgStr("MSG00080"))
            Else
                PutLog(sender.ToString, txtOptNoEnd.Text, "データベースエラー")
                DbFailedProcess()
            End If
            Me.Enabled = True
            Exit Sub
        Else
            PutLog(sender.ToString, txtOptNoEnd.Text, "データベースに保存、結果=" & cnt.ToString)
        End If

        '完成日時の表示
        lblEndTime.Text = serverTime.ToString(DATE_TIME_FORMAT)

        'ICタグに装置IDをセットする　maruyama@tmc 2017/07/18
        IcTag.szEquipID = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応

        'ICタグを「製造完成」にする
        With IcTag
            Dim sztagData As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {12}, {13}",
                                      .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                      .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
            PutLog(sender.ToString, txtOptNoEnd.Text, "ICタグ元データ" & sztagData)
        End With
        If IsNothing(IcTag.szUID) Then
            LastTag.Status = TagProcessStatus.ManufComplete
            IcTag = LastTag
            TagWriteBack(LastTag)
        Else
            IcTag.Status = TagProcessStatus.ManufComplete
            TagWriteBack(IcTag)
        End If

        If inputLotType = INPUTLOTTYPE_DIFF Then
            '拡散ロットの場合、拡散ロットNoをキーに設備、工程を更新する
            m_cEquipMat.UpdateL_LotDataFromDiffLotNo(IcTag.szDifLotNo, IcTag.szEquipID, IcTag.szProcsCD)
        End If


        ''ヘッダ情報を更新する
        'If UpdateHeader(ProcessStatus.ManufComplete, DateTime.Now.ToString(DATE_TIME_FORMAT_DB)) < 0 Then
        '    DbFailedProcess()
        '    Exit Sub
        'End If

        'PutLog(sender.ToString, txtOptNoEnd.Text, "製造完成")
        Me.Enabled = True

        If m_ProcessStatus = ProcessStatus.Processing Then
            m_ProcessStatus = ProcessStatus.ManufComplete

            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If

    End Sub
    '<<20180111 兪

    ' 製造完成時のチェック(必要な画面のみ)
    Protected Overridable Function ManufCompCheck() As Boolean
        ' 基本はノーチェック
        Return True
    End Function

    '******************************************************************************
    '*  「計上完成」クリック処理<完成>
    '******************************************************************************
    Protected Sub btnTotalComp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotalComp.Click

        PutLog(sender.ToString, txtOptNoEnd.Text, "ボタンクリック")
        '不良内容をSF画面に表示する 2020/8/7 56
        IcTag.iFrameIDUse = CInt(m_cEquipMat.getframeIDUse(IcTag.szLotNo))
        PutLog(Me.ToString, "FRAME ID", "IcTag.szLotNo=" & IcTag.szLotNo & "|m_szFrameid_comp=" & m_szFrameid_comp & "|iFrameIDUse=" & IcTag.iFrameIDUse & "|doChkFrameID=" & doChkFrameID())

        'If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 And doChkFrameID() Then 'Then UPD MIAOJF 2020/07/28
        '    PutLog(Me.ToString, "FRAME ID", "do")
        '    'setErrorInfo()
        '    If Not setFrameInfo_OP() Then
        '        PutLog(Me.ToString, "FRAME ID", "error")
        '        HideCommandWaiting()
        '        CommandFailed()
        '        setCheckInfo(getMsgStr("MSG10062", "框架信息"))
        '        Exit Sub
        '    End If

        '    getFrameInfo() 'add Miaojf 2020/8/11 Ver.58
        '    PutLog(Me.ToString, "FRAME ID", "setErrorInfoOnlyNG")
        '    Call setErrorInfoOnlyNG()
        'Else
        '    PutLog(Me.ToString, "FRAME ID", "is not frameID")
        '    '拡散ロットの場合は、不良数をWOKから取得する
        '    dgvError.DataSource = m_cLotBadData.GetDefectData(IcTag.szLotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
        '    '<<20180113 佐川
        '    'ADD 苗 2018/1/18 BEGIN
        '    If IsNothing(dgvError) OrElse dgvError.DataSource.rows.count() = 0 Then
        '        dgvError.DataSource = m_cLotDefect.GetDefectData(IcTag.szLotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
        '    End If
        '    lblCompleteCnt.Text = CInt(lblInputCnt.Text) - CInt(lblFailedCnt.Text)
        'End If
        ''ADD MIAO 20200407 END
        'PutLog(Me.ToString, "FRAME ID", "end")

        ''空芯片（DB)
        'setEmptyChips()
        'PutLog(Me.ToString, "FRAME ID", "不良数：" & lblFailedCnt.Text)
        '----------------------------------------------

        '只有一枚的情况下，iFrameIDUse在数据库里是0。所以手动变成1
        If m_cLotDefect.getFrameCount(IcTag.szLotNo) = 1 Then
            IcTag.iFrameIDUse = 1
        End If

        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then 'UPD 苗 2018/1/31 FrameID_Compが１の場合、AtlasのフレームMAP編集を表示する
            '工程、lotのFrameID管理フラグは両方とも１の場合、ATLASの不良項目画面を呼び出します。

            getFrameInfo() 'add Miaojf 2020/8/11 Ver.58

            Call setErrorInfoOnlyNG()

            'UPD 苗 2018/1/31 FrameID_Compが１の場合、AtlasのフレームMAP編集を表示しなくて、SF画面の項目を再表示（フレーム数、X印数、X印枚数、空チップ数）
        ElseIf m_szFrameid_comp = 2 And IcTag.iFrameIDUse = 1 Then
            Call setErrorInfoOnlyNG()
            Exit Sub 'ADD 苗 2018/2/3 
        Else
            GetDefectCata()
            Call setCompleteCnt()
        End If 'ADD 苗 2018/1/26 END　フレームID対応

        Me.Refresh()

        'ADD 苗 2018/1/10　完成数の更新
        If isRackNoFlow() = True Then
            If lblEmptyChipsCnt.Text = "" Then lblEmptyChipsCnt.Text = "0"
            If CInt(lblEmptyChipsCnt.Text) > 0 Then
                Dim dt1 As DataTable
                dt1 = m_cLotDefect.getWBKaraFrameInfo(txtLotNo.Text, lblEquipID.Text)
                If IsNothing(dt1) OrElse dt1.Rows.Count = 0 Then
                    PutLog(sender.ToString, "CompleteCnt1=", CInt(lblCompleteCnt.Text) + CInt(lblEmptyChipsCnt.Text))
                    lblCompleteCnt.Text = CInt(lblCompleteCnt.Text) + CInt(lblEmptyChipsCnt.Text)  '良品数
                Else
                    PutLog(sender.ToString, "未压焊", dt1.Rows(0)("FRAME_ID"))
                    setCheckInfo("存在未压焊完了的框架： " & dt1.Rows(0)("FRAME_ID") & "  ,请手工编辑。")
                    rtnNG_TO_MPC()
                    Exit Sub
                End If
            Else
                PutLog(sender.ToString, "CompleteCnt2=", CInt(lblCompleteCnt.Text) + CInt(lblEmptyChipsCnt.Text))
                lblCompleteCnt.Text = CInt(lblCompleteCnt.Text) + CInt(lblEmptyChipsCnt.Text)  '良品数
            End If

        End If
        '-------------------------------------------------------------------------------------
        If CInt(lblCompleteCnt.Text) + CInt(lblFailedCnt.Text) <> CInt(lblInputCnt.Text) Then
            Dim strContext As String = ""
            If IsNothing(dtError) = False Then
                strContext = "不良内容:"
                For Each dr1 As DataRow In dtError.Rows
                    strContext = strContext & dr1("0") & "|" & dr1("1") & "|" & dr1("2")
                Next
            End If
            setCheckInfo(getMsgStr("MSG00131", "完成数 + 不良数"， "投入数") & vbCr & strContext）
            rtnNG_TO_MPC()
            Exit Sub
        End If

        'ADD MIAO 2018/11/08 Begin
        Dim chkM As String = ""
        chkM = chkMonitoringAPP()
        If chkM <> "0" Then
            'If MsgBox(getMsgStr("MSG10051"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'UPD MIAO 2019/1/9
            setCheckInfo(getMsgStr("MSG10051", chkM)）
            rtnNG_TO_MPC()
            Exit Sub
        End If

        'ADD MIAO 2018/11/08 END
        If txtOptNoEnd.TextLength <= 0 Then
            If AutoManualMode = 0 Then
                txtOptNoEnd.Text = txtOptNoStt.Text
            Else
                MsgBox(getMsgStr("MSG00067"))
                txtOptNoEnd.Focus() ' 20180301 大賀 終了作業者にフォーカスを合わす
                rtnNG_TO_MPC()
                Exit Sub
            End If

        End If

        '検査数をチェックする
        If Not IsCheckQtySet() Then
            PutLog(sender.ToString, txtOptNoEnd.Text, "チェック数未入力、処理終了。")
            Exit Sub
        End If
        'ADD 苗 2018/1/5 BEGIN
        If chkCrossFrame() = False Then
            rtnNG_TO_MPC()
            Exit Sub
        End If
        'ADD 苗 2018/1/17 BEGIN 
        '「組立ロットの場合、良品数、不良数、フレーム数をbSiteに連携できない」の対応
        If inputLotType = INPUTLOTTYPE_ASM Then

            IcTag.iInput = CInt(lblInputCnt.Text)
            IcTag.iFinish = CInt(lblCompleteCnt.Text)
            IcTag.iFailed = CInt(lblFailedCnt.Text)
            'IcTag.iFrame = CInt(lblPcbCnt.Text) 'DEL 苗 2018/1/31 
            IcTag.iCross = CInt(lblCrossCnt.Text)
            IcTag.iCrossFrm = CInt(lblCrossPcbCnt.Text)
            IcTag.iDisposalFrmNum = m_disposalFrmNum 'ADD 苗 2018/1/24
        End If
        'ADD 苗 2018/1/17 END

        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
        If wf_write_flag = WRITE_WAFER Then
            IcTag.waferNum = CInt(lblPcbCnt.Text)
        Else
            IcTag.iFrame = CInt(lblPcbCnt.Text)
        End If
        '<<20180302 大賀 GroupKey入力時ウェハ枚数入力

        '>>20180111 佐川
        '不良数の設定
        settingFaildCount()
        '>>20180111 佐川
        '>>20180113 佐川
        'GroupKey対応初期化
        execCount = 0
        frmGroupKeyResultMsg = Nothing
        '<<20180113 佐川


        'ADD 苗 2018/1/5 END
        If EndCheck() AndAlso lotEndCheck() Then
            NPP.szLotNo = IcTag.szLotNo
            NPP.szDifLotNo = IcTag.szDifLotNo
            NPP.ProcessCD = lblProcessCD.Text
            NPP.EQUIP_ID = g_CURRENT_EQUIP_ID
            NPP.EQUIP_No = lblEquipID.Text
            NPP.OptNoEnd = txtOptNoEnd.Text
            NPP.kindNm = lblkindNm.Text
            NPP.Shape = lblShape.Text
            NPP.PbLayout = lblPbLayout.Text
            '>>20180111 兪
            If inputLotType = INPUTLOTTYPE_DIFF Then
                '>> 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
                For Each tagData In GroupID.Select(Function(item, i) New With {item, i})
                    IcTag = tagData.item
                    lotNo = tagData.item.szLotNo
                    If IcTag.iInput <> 0 Then '2021/8/23 小Lot统合 miaojf
                        TotalComplete(tagData.item)
                    End If '2021/8/23 小Lot统合 miaojf
                    '>>20180113 佐川
                    execCount += 1
                    '<<20180113 佐川
                    GroupID(tagData.i) = IcTag
                Next
                '<< 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
                IcTag = GroupID(0)
                lotNo = IcTag.szLotNo
            Else
                'ADD MIAOJF 20191218 BEGIN
                'setErrorInfo()
                'If AutoManualMode = 1 Then
                '    MsgBox("画面良品数， 不良数， X印数， X印枚数更新完成， 请确认。")
                'End If
                'ADD MIAOJF 20191218 END

                TotalComplete()
            End If
            '<<20180111 兪
            delFinishedLotFromLotList()  'ADD 2020/8/11 Miaojf Ver.58
            totalCompAfter()
        Else
            rtnNG_TO_MPC()
            setCheckInfo("不满足完工条件，请检查设备页的信息是否正确。")
            PutLog(sender.ToString, txtOptNoEnd.Text, "完成条件は満たされていません。処理終了。")
            Exit Sub
        End If

        'If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then
        'Else
        '    SendNPtoMPC()
        'End If

        '>>20180117 佐川
        '計上完成の終了時のみ実施
        'If m_ProcessStatus = ProcessStatus.TotalComplete Or (lblProcessCD.Text = "S42" And m_ProcessStatus = ProcessStatus.TagSet) Then
        If btnStart.Text = getMsgStr("MSG10014") Or btnStart.Text = getMsgStr("MSG00121") Then
            '不良項目を履歴テーブルに書き込み
            If inputLotType = INPUTLOTTYPE_DIFF Then
                '>>2018/02/19 安部 BugFix g_EQUIP_NO => g_CURRENT_EQUIP_ID
                'm_cLotDefect.InsertHistryDefect(GroupID(0).szDifLotNo, GroupID(0).szProcsCD, g_EQUIP_NO, True) 'UPD 苗 2018/1/19 装置No.の対応
                m_cLotDefect.InsertHistryDefect(GroupID(0).szDifLotNo, GroupID(0).szProcsCD, g_CURRENT_EQUIP_ID, True) 'UPD 苗 2018/1/19 装置No.の対応
                '<<2018/02/19 安部 BugFix g_EQUIP_NO => g_CURRENT_EQUIP_ID
            Else
                '>>2018/02/19 安部 BugFix g_EQUIP_NO => g_CURRENT_EQUIP_ID
                'm_cLotDefect.InsertHistryDefect(GroupID(0).szLotNo, GroupID(0).szProcsCD, g_EQUIP_NO, False) 'UPD 苗 2018/1/19 装置No.の対応
                m_cLotDefect.InsertHistryDefect(GroupID(0).szLotNo, GroupID(0).szProcsCD, g_CURRENT_EQUIP_ID, False) 'UPD 苗 2018/1/19 装置No.の対応
                '<<2018/02/19 安部 BugFix g_EQUIP_NO => g_CURRENT_EQUIP_ID
            End If
            setinitializForm_FLG()

            If initializForm_FLG Then
                '画面表示を初期化
                initializForm()
            End If
        End If
        '<<20180117 佐川
        'clearForm()
    End Sub
    Overridable Sub clearForm()

    End Sub
    Overridable Function isRackNoFlow()
        Return False
    End Function
    ''' <summary>
    ''' DB是进行多个lot的着完工，当第一个完成后，应该从Lotlist里删除掉
    ''' </summary>
    Overridable Sub delFinishedLotFromLotList()

    End Sub
    Public Sub rtnNG_TO_MPC()
        If AutoManualMode = 0 Then
            Dim rtnIU As String
            Dim rtnNP As String

            NP_IU_RTN = False 'ADD 2020/8/17 miaojf Ver.70
            rtnIU = COMMAND_NG
            rtnNP = NG

            'TODO:追加要
            'NPコマンドを送信
            Dim strMPCCommand As String
            With IcTag
                strMPCCommand = createStORCompCommandStr(COMMAND_NP, rtnNP, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
                                        lblEquipID.Text, "", "", txtOptNoEnd.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
            End With
            PutLog(Me.ToString, "rtn sendCommand", strMPCCommand)
            m_cEquipCommandControl.CommandSend(strMPCCommand)

            'IUコマンドを送信
            'If LH_FLAG = True Then
            sendResponseCommand(COMMAND_IU, rtnIU)
            'End If

            LN_FLAG = False
            LH_FLAG = False
        End If
    End Sub
    ''' <summary>
    ''' A工程の着工・完工
    ''' </summary>
    Private Sub AProcDoStartComplete()

        '--------- 抜取検査  BEGIN ---------
        If RandCheckFLAG = True And STS_SUCCESS.Equals(outHeader.Status) And lblProcessCD.Text <> AProcCD() Then
            Dim szLotNoSend As String = FixCharSpace(IcTag.szLotNo, 30)
            '----------- S工程抜取検査 BEGIN -----------
            Dim objRCHistory As New clsRandCheckHistory
            Dim dtRCHistory As DataTable
            Dim KeijyoFlg As Boolean = True
            Dim A_PROC_SKIP As Boolean = True 'True A工程SKIP
            dtRCHistory = objRCHistory.selectRandCheckHistory(szLotNoSend.Trim, lblProcessCD.Text, g_EQUIP_NO, "", "")
            If IsNothing(dtRCHistory) = False AndAlso dtRCHistory.Rows.Count > 0 Then
                A_PROC_SKIP = False
                If DBNullTOblank(dtRCHistory.Rows(0)("Status")） = OK Then
                    If AProcStartCompleteFLG() = True Then
                        If MsgBox(getMsgStr("MSG10056"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                            KeijyoFlg = True
                        Else
                            KeijyoFlg = False
                        End If
                    End If
                ElseIf DBNullTOblank(dtRCHistory.Rows(0)("Status")) = NG Then
                    KeijyoFlg = False
                    MsgBox(getMsgStr("MSG10057"))
                Else
                    KeijyoFlg = False

                    updateRCRackID()
                End If
                'TODO:削除20200404
                'Else
                '    A_PROC_SKIP = True
            End If
            '----------- S工程抜取検査 END   ----------- 
            If AProcStartCompleteFLG() = True Then 'A工程は着完工やるか判断(S41,S51:True,S42:False)
                Dim clientProcCd As String
                Dim lossInf() As InSiteWebService.LossData = {}
                Dim LossQtySum As Integer = 0 'ADD 苗 2018/2/3


                '----------- A工程着工 BEGIN  ----------- 
                Dim inputBsite As New InSiteWebService.InMoveIn
                Dim outputBsite As New InSiteWebService.OutMoveIn

                clientProcCd = m_cEquipMat.GetBsiteClientString(AProcCD)

                inputBsite.Employee = txtOptNoEnd.Text  '開始作業者
                inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                inputBsite.Machine = g_EQUIP_NO 'A_PROC_EQUIP         '装置No
                inputBsite.IgnoreLimitTime = True   '強制着工
                inputBsite.MoveInForWaferLot = False   '拡散ロット着工
                If Not String.IsNullOrEmpty(outWeekCode) Then
                    inputBsite.WeeklyCode = outWeekCode '週コード
                End If

                outputBsite = MoveInService_Execute(inputBsite, clientProcCd)
                '戻り情報を保持
                outHeader = outputBsite.Header
                outLotInfo = outputBsite.LotInf
                'A工程の着工履歴作成
                m_cEquipMat.saveAProcResultForRC(lblProcessCD.Text, AProcCD, "1", szLotNoSend.Trim)
                '----------- A工程着工  END   ----------- 

                '    '----------- A工程完工 BEGIN  ----------- 
                If KeijyoFlg = True OrElse A_PROC_SKIP = True Then

                    Dim dtFrameNG As DataTable = Nothing
                    If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
                        dtFrameNG = getFrameNG(AProcCD)
                    Else
                        '拡散ロットの場合は、不良数をWOKから取得する
                        dtFrameNG = m_cLotBadData.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, AProcCD)

                        '<<20180113 佐川
                        'ADD 苗 2018/1/18 BEGIN
                        If IsNothing(dtFrameNG) OrElse dtFrameNG.Rows.Count() = 0 Then
                            dtFrameNG = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, AProcCD)
                        End If
                    End If

                    'ADD 苗 2018/1/18 END
                    If Not (IsNothing(dtFrameNG) OrElse dtFrameNG.Rows.Count <= 0) Then
                        'szCmdDefectCntSend = FixCharZero(dgvError.Rows.Count, 6)
                        ReDim lossInf(dtFrameNG.Rows.Count - 1)
                        For i = 0 To dtFrameNG.Rows.Count - 1
                            'szCmdDefectCntSend &= ":" & FixCharSpace(dgvError(0, i - 1).Value.ToString, 5) & ":" & FixCharSpace(dgvError(2, i - 1).Value.ToString, 6)
                            'b-Site不良数セット
                            lossInf(i) = New InSiteWebService.LossData

                            lossInf(i).LossReason = dtFrameNG(i)(dtFrameNG.Columns.Count - 3).ToString
                            lossInf(i).LossQty = dtFrameNG(i)(dtFrameNG.Columns.Count - 1).ToString

                            LossQtySum += CInt(lossInf(i).LossQty) 'ADD 苗 2018/2/3
                        Next
                    End If
                    Dim inputBsiteStd As New InSiteWebService.InMoveStd
                    Dim outputBsiteStd As New InSiteWebService.OutMoveStd
                    Dim frameinfo As Hashtable = Nothing
                    inputBsiteStd.Employee = txtOptNoEnd.Text  '終了作業者
                    inputBsiteStd.Lot = szLotNoSend.Trim       'ロットNo
                    inputBsiteStd.Machine = g_EQUIP_NO 'A_PROC_EQUIP         '装置No
                    inputBsiteStd.IgnoreWarning = True    '強制着工
                    inputBsiteStd.LossInf = lossInf            '不良数 

                    If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
                        frameinfo = getFrameInfo()
                        If IsNothing(frameinfo) OrElse Val(frameinfo("totalPkgCnt").ToString()) = 0 Then
                            HideCommandWaiting()
                            CommandFailed()
                            MsgBox（getMsgStr("MSG10060"))
                            Exit Sub
                        Else

                            'inputBsite.Qty = lblCompleteCnt.Text    '完成数
                            'UPD 苗 2018/2/3 BEGIN
                            'If LossQtySum = 0 Then 'And IcTag.iFinish = 0 Then
                            '    inputBsiteStd.Qty = Val(frameinfo("totalPkgCnt").ToString())    '投入数
                            'Else
                            inputBsiteStd.Qty = Val(frameinfo("totalOkCnt").ToString())    '完成数
                            'End If
                            'UPD 苗 2018/2/3 END
                            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力

                            inputBsiteStd.Qty2 = Val(frameinfo("frameCnt").ToString()) 'フレーム枚数’ADD 苗　2018/1/17
                        End If
                    Else
                        inputBsiteStd.Qty = IcTag.iInput - LossQtySum   '投入数
                        inputBsiteStd.Qty2 = IcTag.iFrame 'フレーム枚数’ADD 苗　2018/1/17

                    End If
                    '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                    If Not String.IsNullOrEmpty(outWeekCode) Then
                        inputBsiteStd.WeeklyCode = outWeekCode '週コード
                    End If
                    PutLog(Me.ToString, IcTag.szProcsCD & "数量 ： ", inputBsiteStd.Lot.ToString & " : " & inputBsiteStd.Qty.ToString)
                    outputBsiteStd = MoveStdService_Execute(inputBsiteStd, clientProcCd)
                    '戻り情報を保持
                    outHeader = outputBsiteStd.Header
                    outLotInfo = outputBsiteStd.LotInf

                    If STS_SUCCESS.Equals(outHeader.Status) Then
                        'A工程の完工履歴作成
                        m_cEquipMat.saveAProcResultForRC(lblProcessCD.Text, AProcCD, "3", szLotNoSend.Trim, frameinfo)
                        'MsgBox(AProcCD() & "工程 计上完成 ", MsgBoxStyle.Information)

                        SyncLotInfo(AProcCD, IcTag.szLotNo)
                    Else
                        MsgBox(AProcCD() & "工程 计上失败 ：" & outHeader.Message, MsgBoxStyle.Critical)
                    End If

                End If
            End If
            '    '----------- A工程完工  END   -----------
        End If
    End Sub

    Public Sub SyncLotInfo(strProcCD As String, lotNo As String)
        Dim m_cEquipMat As New clsDbEquipMat
        Dim m_cLotInfo As New clsDbLotInfo

        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = lotNo
        Dim clientStr As String = m_cEquipMat.GetBsiteClientString(strProcCD)
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        If Not IsNothing(viewLotServiceInfo) AndAlso STS_SUCCESS.Equals(viewLotServiceInfo.Header.Status) Then

            m_cLotInfo.SaveTagLotInfo(lotNo, viewLotServiceInfo.LotInf.Operation)
            '>>20171202 兪
        Else
            'MsgBox("组立Key No在bSite里不存在 或者 连接不上bSite,请联系相关人员。", MsgBoxStyle.Information)
            '<<20171202 兪
        End If
    End Sub
    Overridable Sub totalCompAfter()

    End Sub

    '>>20180111 兪
    Private Sub TotalComplete(Optional ByVal tagData As TagData = Nothing)
        Dim sender As Object = btnTotalComp
        If isCompleteCallAtlas() Then
            ' BsiteではなくATLAS画面を呼び出す
            If CallAtlasExec() Then
                ' 成功時はDBの更新

                Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " 成功時はDBの更新")

                '>>20180328 大賀 No122 DBサーバ時刻を使用する
                'serverTime = Now()
                serverTime = m_cData.GetServerTime()
                '<<20180328 大賀 No122 DBサーバ時刻を使用する
                'ヘッダ情報を更新する
                If Not IsNothing(tagData.szLotNo) Then 'UPD 苗 2018/1/24 tagDataの値が無くても、Nothingではない
                    UpdateHeader(ProcessStatus.TotalComplete, serverTime.ToString(DATE_TIME_FORMAT_DB), tagData)
                Else
                    tagData = IcTag
                    UpdateHeader(ProcessStatus.TotalComplete, serverTime.ToString(DATE_TIME_FORMAT_DB))
                End If
                '完成情報をDBに保存
                If SaveTotalInfo() < 0 Then
                    DbFailedProcess()
                    Exit Sub
                End If

                '完成日時の表示
                lblEndTime.Text = serverTime.ToString(DATE_TIME_FORMAT)

                'ICタグの装置IDをNULLでセットするmaruyama@tmc 2017/07/18
                tagData.szEquipID = ""
                'ICタグの工程コードに次工程の工程コードをセットするmaruyama@tmc 2017/07/20
                tagData.szProcsCD = nextProcCode

                With tagData
                    Dim sztagData As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {12}, {13}",
                                  .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                  .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
                    PutLog(Me.ToString, txtOptNoEnd.Text, "ICタグ元データ:   " & sztagData)
                End With

                tagData.iInput = CInt(lblInputCnt.Text)
                tagData.iFinish = CInt(lblCompleteCnt.Text)
                tagData.iFailed = CInt(lblFailedCnt.Text)
                '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                If wf_write_flag = WRITE_WAFER Then
                    tagData.waferNum = CInt(lblPcbCnt.Text)
                Else
                    tagData.iFrame = CInt(lblPcbCnt.Text)
                End If
                '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                tagData.iCross = CInt(lblCrossCnt.Text)
                tagData.iCrossFrm = CInt(lblCrossPcbCnt.Text)
                tagData.fQflag = CBool(btnQflag.Tag)
                tagData.fTestflag = m_fTestFlg
                tagData.fCheckflag = CBool(btnChecked.Tag)
                tagData.OnHoldSt = m_IsHolding
                tagData.iDisposalFrmNum = m_disposalFrmNum 'ADD 苗 2018/1/24
                LastTag.iInput = tagData.iInput
                LastTag.iFinish = tagData.iFinish
                LastTag.iFailed = tagData.iFailed
                '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                If wf_write_flag = WRITE_WAFER Then
                    LastTag.waferNum = tagData.waferNum
                Else
                    LastTag.iFrame = tagData.iFrame
                End If
                '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                LastTag.iCross = tagData.iCross
                LastTag.iCrossFrm = tagData.iCrossFrm
                LastTag.iDisposalFrmNum = m_disposalFrmNum 'ADD 苗 2018/1/24
                m_IsHolding = OnHoldStatus.Normal
                'ICタグを「着工待ち」にする 
                If IsNothing(tagData.szUID) Then
                    LastTag.Status = TagProcessStatus.Ready
                    tagData = LastTag
                    TagWriteBack(LastTag)
                Else
                    tagData.Status = TagProcessStatus.Ready
                    TagWriteBack(tagData)
                End If

                If inputLotType = INPUTLOTTYPE_DIFF Then
                    '拡散ロットの場合、拡散ロットNoをキーに設備、工程を更新する
                    m_cEquipMat.UpdateL_LotDataFromDiffLotNo(tagData.szDifLotNo, tagData.szEquipID, tagData.szProcsCD)
                End If

                Threading.Thread.Sleep(20)

                If m_ProcessStatus <> ProcessStatus.Failed Then
                    m_ProcessStatus = ProcessStatus.TotalComplete
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                End If

                m_cFactoryInfo.GetIcTagSwVersion(g_CURRENT_EQUIP_TYPE)
                'frmInital.UpdateMe()

                ConfScreenItem()

                ' 画面呼び出しに失敗
            End If
        Else
            'Bsite待ちのメッセージを表示
            ShowBsiteWaiting()
            Select Case CheckWarning()
                Case DefectJudgement.OK
                    'コマンド発信
                    m_CmdType = CommandType.JO
                    '>>20180111 佐川
                    SendCommand(m_CmdType, False, IcTag)
                    '<<20180111 佐川
                Case DefectJudgement.WARNING
                    If MsgBox(getMsgStr("MSG00032"), MsgBoxStyle.YesNo, "Warning") = MsgBoxResult.Yes Then
                        PutLog(sender.ToString, txtOptNoEnd.Text, "不良率は管理値を超えました。強制実行。")
                        '強制実行コマンド発信
                        m_CmdType = CommandType.JO
                        '>>20180111 佐川
                        SendCommand(m_CmdType, True, IcTag)
                        '<<20180111 佐川
                    Else
                        PutLog(sender.ToString, txtOptNoEnd.Text, "不良率は管理値を超えました。終了。")
                        CommandFailed()
                    End If
                Case DefectJudgement.HOLD
                    '強制実行コマンド発信
                    m_CmdType = CommandType.JO
                    '>>20180111 佐川
                    SendCommand(m_CmdType, True, IcTag)
                    '<<20180111 佐川
                Case DefectJudgement.ERR
                    PutLog(sender.ToString, txtOptNoEnd.Text, "Lot、顧客情報を取得できません。")
                    MsgBox(getMsgStr("MSG00068"))
                    CommandFailed()
            End Select

        End If
    End Sub
    '<<20180111 兪

    ' 計上完成時にATLAS画面を呼び出すかチェック(必要な画面のみ)
    Protected Overridable Function isCompleteCallAtlas() As Boolean
        ' 基本は呼び出さない
        Return False
    End Function

    ' 計上完成時にATLAS画面を呼び出す処理
    Protected Overridable Function CallAtlasExec() As Boolean
        ' ここは呼ばれる場合は必ず各画面で実装。Warning対策でTrueを返す
        Return True
    End Function

    ''' <summary>
    ''' 検査数をチェックする
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Overridable Function IsCheckQtySet() As Boolean
        '>>20171202 兪
        Dim fChk As Boolean = True
        If Not IsNumeric(lblPcbCnt.Text) Then
            lblPcbCnt.BackColor = Color.Red
            fChk = False
        End If
        If Not IsNumeric(lblCrossCnt.Text) Then
            lblCrossCnt.BackColor = Color.Red
            fChk = False
        End If
        If Not IsNumeric(lblCrossPcbCnt.Text) Then
            lblCrossPcbCnt.BackColor = Color.Red
            fChk = False
        End If
        Return fChk
        '<<20171202 兪
    End Function

    '******************************************************************************
    '*  「不良項目入力」クリック処理
    '******************************************************************************
    Protected Sub btnErrInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnErrInput.Click
        PutLog(sender.ToString, "不良項目入力", "ボタンクリック")
        Dim fTimer As Boolean = TimerTag.Enabled
        If fTimer Then
            TimerTag.Stop()
        End If
        'ADD 苗 2018/2/7 BEGIN
        'If IcTag.iFrameIDUse = 0 Then 'DEL 苗 2018/2/8
        IcTag.iFrameIDUse = CInt(m_cEquipMat.getframeIDUse(IcTag.szLotNo))
        'End If 'DEL 苗 2018/2/8
        'ADD 苗 2018/2/7 END


        'ADD 苗 2018/1/26 BEGIN フレームID対応

        '只有一枚的情况下，iFrameIDUse在数据库里是0。所以手动变成1
        If m_cLotDefect.getFrameCount(IcTag.szLotNo) = 1 Then
            IcTag.iFrameIDUse = 1
        End If

        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then 'UPD 苗 2018/1/31 FrameID_Compが１の場合、AtlasのフレームMAP編集を表示する
            '工程、lotのFrameID管理フラグは両方とも１の場合、ATLASの不良項目画面を呼び出します。
            '外部EXEを呼び出す
            Dim strRetStatus As String = Execute_Command(COMMON_PROC_CD, EXEC_PG_TAG_BAD, IcTag.szProcsCD, g_EQUIP_NO, IcTag.szLotNo) 'UPD 苗 2018/1/30
            '戻り値による処理は未定のため、現在は未実装
            If strRetStatus <> "0" Then
                MsgBox(getMsgStr("MSG10009", strRetStatus))
                Exit Sub
            End If
            'Call getAtlasUpdatedDetail()
            getFrameInfo() 'add Miaojf 2020/8/11 Ver.58
            Call setErrorInfoOnlyNG()

            'UPD 苗 2018/1/31 FrameID_Compが１の場合、AtlasのフレームMAP編集を表示しなくて、SF画面の項目を再表示（フレーム数、X印数、X印枚数、空チップ数）
        ElseIf m_szFrameid_comp = 2 And IcTag.iFrameIDUse = 1 Then
            'Call getAtlasUpdatedDetail()
            Call setErrorInfoOnlyNG()
            Exit Sub 'ADD 苗 2018/2/3 
        Else

            '>>20171020 兪 不良入力統一化
            'If g_CURRENT_EQUIP_TYPE = DEF_ID_DB OrElse
            '   g_CURRENT_EQUIP_TYPE = DEF_ID_DBAFC OrElse
            '   g_CURRENT_EQUIP_TYPE = DEF_ID_WB OrElse
            '   lblProcessCD.Tag = PROC_CD_PLASMA_WB Then
            '    Dim frmMap As New frmErrorMap
            '    frmMap.htMsgMst = htMsgMst
            '    frmMap.lblLotNo.Text = lblLotNo.Text
            '    frmMap.EquipID = lblEquipID.Text
            '    frmMap.StartPosition = FormStartPosition.CenterScreen
            '    frmMap.ShowDialog()
            'ElseIf g_CURRENT_EQUIP_TYPE = DEF_ID_INSP Then
            '    Dim frmErrCode As New frmLotCategoryCode
            '    frmErrCode.LotNo = lblLotNo.Text
            '    frmErrCode.EquipID = lblEquipID.Text
            '    frmErrCode.KouteiCD = IcTag.szProcsCD
            '    frmErrCode.StartPosition = FormStartPosition.CenterScreen
            '    frmErrCode.ShowDialog()
            'Else
            Dim frmErrInput As New frmLotCategoryInput
            '>>20180113 安部
            If m_szPreProcLotType = "0" Then
                frmErrInput.LotNo = txtDiffLot.Text
            Else
                frmErrInput.LotNo = lotNo
            End If
            '<<20180113 安部

            frmErrInput.EquipID = g_CURRENT_EQUIP_ID 'UPD 苗 2018/1/19 装置No.の対応
            frmErrInput.KouteiCD = IIf(AProcCD() = "", IcTag.szProcsCD, AProcCD)
            'frmErrInput.ErrorTable = dtError
            frmErrInput.StartPosition = FormStartPosition.CenterScreen
            frmErrInput.preProcCompleteCnt = CInt(lblInputCnt.Text)
            frmErrInput.ShowDialog()
            'End If
            '<<20171020 兪 不良入力統一化
        End If 'ADD 苗 2018/1/26 END　フレームID対応
        '不良カタゴリ再取得
        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
            'getFrameInfo()
        Else
            GetDefectCata()
        End If


        Me.Refresh()
        If fTimer Then
            '20170714>>
            If m_fIcTagUsed Then
                TimerTag.Start()
            End If
            '<<20170714
        End If

        'ADD 苗 2018/1/10　完成数の更新
        Call setCompleteCnt()

    End Sub

    '******************************************************************************
    '*  「ロットキャンセル」クリック処理
    '******************************************************************************
    Protected Overridable Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        'ADD MIAO 2018/11/08 Begin
        Dim chkM As String = ""
        chkM = chkMonitoringAPP()
        If chkM <> "0" Then
            'If MsgBox(getMsgStr("MSG10051"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'UPD MIAO 2019/1/9
            MsgBox(getMsgStr("MSG10051", chkM)）
            Exit Sub
        End If

        'ADD MIAO 2018/11/08 END

        'ADD 苗 2018/2/6 BEGIN 確認メッセージ
        If MsgBox(getMsgStr("MSG10021"), MsgBoxStyle.YesNo) = MsgBoxResult.No Then
            Exit Sub
        End If
        'ADD 苗 2018/2/6 END

        PutLog(sender.ToString, txtOptNoStt.Text, "ボタンクリック")

        '>>20180113 佐川
        'GroupKey対応初期化
        execCount = 0
        frmGroupKeyResultMsg = Nothing
        '<<20180113 佐川

        'コマンド発信
        m_CmdType = CommandType.JC
        '>>20180111 兪
        If inputLotType = INPUTLOTTYPE_DIFF Then
            '>> 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            For Each tagData In GroupID.Select(Function(item, i) New With {item, i})
                IcTag = tagData.item
                lotNo = tagData.item.szLotNo
                '>>20180111 佐川
                SendCommand(m_CmdType, False, tagData.item)
                '<<20180111 佐川
                '>>20180112 佐川
                execCount += 1
                '<<20180112 佐川
                GroupID(tagData.i) = IcTag
            Next
            '<< 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            IcTag = GroupID(0)
            lotNo = IcTag.szLotNo
        Else
            '>>20180111 佐川
            SendCommand(m_CmdType, False, IcTag)
            '<<20180111 佐川
        End If
        '<<20180111 兪

        '>>20180118 佐川
        'キャンセル処理が正常終了時のみ実施
        If m_ProcessStatus = ProcessStatus.Canceled Then
            Call clearData()
            '不良項目を削除する
            If inputLotType = INPUTLOTTYPE_DIFF Then
                m_cLotDefect.DeleteDefectCategory(GroupID(0).szDifLotNo, GroupID(0).szProcsCD, g_EQUIP_NO) 'UPD 苗 2018/1/19 装置No.の対応
            Else
                m_cLotDefect.DeleteDefectCategory(GroupID(0).szLotNo, GroupID(0).szProcsCD, g_EQUIP_NO) 'UPD 苗 2018/1/19 装置No.の対応
            End If

            '画面表示を初期化
            initializForm()
            canceledAfter()
        End If
        '<<20180118 佐川


    End Sub
    Overridable Sub canceledAfter()

    End Sub

    '******************************************************************************
    '*  「不良項目」テーブル処理
    '******************************************************************************
    Protected Sub dgvError_DataSourceChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvError.DataSourceChanged
        Dim fTimer As Boolean = TimerTag.Enabled
        If fTimer Then
            TimerTag.Stop()
        End If

        Dim dgv As DataGridView = CType(sender, DataGridView)
        If IsNothing(dtError) OrElse dtError.Rows.Count <= 0 Then
            dgv.Visible = False
            Exit Sub
        End If

        dgv.Visible = True
        For Each row As DataGridViewRow In dgv.Rows
            row.Height = 25
        Next

        '>>20170717
        If IsNothing(dgv.Columns("コード")) Then Exit Sub
        dgv.Columns("コード").Width = 65
        dgv.Columns("コード").HeaderText = getMsgStr("MSG00130")
        dgv.Columns("コード").SortMode = DataGridViewColumnSortMode.NotSortable
        dgv.Columns("不良内容").Width = 165
        '<<20170717
        dgv.Columns("不良内容").SortMode = DataGridViewColumnSortMode.NotSortable
        dgv.Columns("数量").Width = 45
        dgv.Columns("数量").SortMode = DataGridViewColumnSortMode.NotSortable
        dgv.Columns("数量").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        'dgv.Enabled = False
        dgv.EnableHeadersVisualStyles = False
        dgv.ClearSelection()

        Dim iCnt As Integer = 0
        For Each dr As DataRow In dtError.Rows
            Dim cnt As Integer
            If IsNumeric(dr("数量")) Then
                cnt = CInt(dr("数量"))
            Else
                cnt = 0
            End If
            iCnt += cnt
        Next
        ErrorCount = iCnt

        If fTimer Then
            '>>20170717
            If m_fIcTagUsed Then
                TimerTag.Start()
            End If
            '<<20170717
        End If
    End Sub

    '******************************************************************************
    '*  「Qフラグ」ボタン処理
    '******************************************************************************
    Protected Sub btnQflag_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnQflag.Click
        PutLog(sender.ToString, txtOptNoStt.Text, "ボタンクリック")
        m_DelayType = DelayType.Qflag
        btnQflagPress()
    End Sub

    Protected Sub btnQflagPress()
        If btnQflag.Tag Then
            btnQflag.BackColor = Drawing.SystemColors.Control
            btnQflag.UseVisualStyleBackColor = True
            btnQflag.Tag = False
        Else
            btnQflag.BackColor = ERROR_INIT_COLOR
            btnQflag.Tag = True
        End If
    End Sub

#End Region

#Region "画面ヘッダー"
    '開始/終了作業者バーコード入力処理
    Protected Sub btnOptNoStt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptNoStt.Click
        txtOptNoStt.Enabled = True
        txtOptNoStt.Focus()
        txtOptNoStt.SelectAll()
        '--------------------------------------
        Time_LoginUser.Stop()
        pnlUserLogin.Visible = True
        Me.pnlUserLogin.BringToFront()
        txtUser.Select()
        Exit Sub
        '--------------------------------------
    End Sub

    Protected Sub btnOptNoEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptNoEnd.Click
        txtOptNoEnd.Enabled = True
        txtOptNoEnd.Focus()
        txtOptNoEnd.SelectAll()
        '--------------------------------------
        Time_LoginUser.Stop()
        pnlUserLogin.Visible = True
        Me.pnlUserLogin.BringToFront()
        txtUser.Select()
        Exit Sub
        '--------------------------------------
    End Sub

    Private Sub btnLotTxt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLotTxt.Click
        txtLotNo.Enabled = True
        txtLotNo.Focus()
        txtLotNo.SelectAll()
    End Sub

    Protected Sub txtOptNoStt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOptNoStt.KeyPress
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            'PutLog(btnOptNoStt.ToString, txtOptNoStt.Text, "開始作業者No入力")

            Dim txtOptor As TextBox = CType(sender, TextBox)
            txtOptor.BackColor = Color.Yellow
            ' >> 20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
            'txtOptor.Enabled = False
            setNextFocus(OPERATER_INPUT_TYPE.START_OPE, txtOptor)
            ' << 20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
            '条件を満たせば着工を仕掛ける
            'If Not String.IsNullOrEmpty(IcTag.szUID) AndAlso IcTag.Status = TagProcessStatus.Ready Then
            If IcTag.Status = TagProcessStatus.Ready Then
                MatCollAll()
                'If m_fColl AndAlso txtOptNoStt.TextLength > 0 Then
                '    If m_ProcessStatus = ProcessStatus.TagSet OrElse _
                '       m_ProcessStatus = ProcessStatus.Preprocess Then
                '        m_ProcessStatus = ProcessStatus.Preprocess
                '        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                '    End If
                'End If
            End If

        End If
    End Sub

    Protected Sub txtLotNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtLotNo.KeyPress
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            PutLog(btnOptNoStt.ToString, txtOptNoStt.Text, "組立ロットＮｏ.")
            strOptNoEnd = "" 'ADD 苗 2018/4/2
            Dim txtOptor As TextBox = CType(sender, TextBox)
            txtOptor.BackColor = Color.Yellow
            txtOptor.Enabled = False
            Call btnTag_Click(sender, e)
            If m_MoveInCheck = False Then
                m_MoveInCheck = True
                Exit Sub
            End If

            'ADD 苗 2018/5/8 BEGIN
            If Me.lblProcessCD.Text = PROC_CD_MOLDS Or lblProcessCD.Text = PROC_CD_MARK Then
                Me.Text = strTitle & " " & txtLotNo.Text.ToUpper 'ADD 苗 2018/4/19　DEL 苗 2018/4/23　ADD 苗 2018/5/8
            End If
            'ADD 苗 2018/5/8 END
            If txtLotNo.Text = "" Then Exit Sub

            chkUserEndTime() 'ADD MIAO 2019/10/1
            If chkRandCheck(txtLotNo.Text.ToUpper) Then
                setRandCheckInfo("LOT：" & txtLotNo.Text.ToUpper)
            End If
            'TimerTag.Stop()
            If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then
                setBeforeRackNo()
            End If

            If IcTag.Status <> ProcessStatus.Ready Then
                Button1.Enabled = True
            Else
                Button1.Enabled = False
            End If
            If IcTag.frameIDFlag = True Then
                'btnTmpChg.Visible = True
            Else
                btnTmpChg.Visible = False
            End If
            Dim ScoreCheck As Boolean = True
            For i As Integer = 0 To m_iScore.Length - 1
                If m_iScore(i) = PASS_SCORE_WAIT_CHECK Then
                    ScoreCheck = False
                    Exit For
                End If
            Next
            setKeyNoAfferControlFocus()
            If ScoreCheck = False Then Exit Sub
            'ADD 苗 2019/12/18 BEGIN
            '自動着完工工程であれば、手動着工時もLCコマンドを送信する。
            If AutoManualMode = 0 Then
                SyncLotInfo()
                If chkLN() And LC_SEND_FLG = True Then
                    'ADD Miaojf 2020/07/17 Begin
                    'If chkMoveInByAutoMode() = False Then
                    '    Exit Sub
                    'End If
                    doLC()
                    'ADD Miaojf 2020/07/17 END
                    'Dim tmpLotNo As String = txtLotNo.Text
                    'Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)

                    'Dim pkgValue As String = getLCPackage()
                    'If m_EquipInstPattern <> "00" Then
                    '    If pkgValue = "too Much" Then
                    '        setCheckInfo("程序被设定多条，请确认。")
                    '        Exit Sub
                    '    End If
                    '    If pkgValue = "" Then
                    '        setCheckInfo("没有设定程序，请确认。")
                    '        Exit Sub
                    '    End If
                    'End If
                    'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "", lblInputFrm.Text, pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
                    '    Command_LD_Received = False
                    '    ShowCommandWaiting()
                    ' End If

                End If
            Else

                TimerBegin.Start()
                ChkPLT()
            End If
            'ADD 苗 2019/12/18 END
            'TimerTag.Start()

        End If

    End Sub

    Overridable Sub chkPLT()

    End Sub
    Overridable Function chkLN() As Boolean
        If IcTag.Status = TagProcessStatus.Ready Then
            Return True
        Else
            Return False
        End If
    End Function
    Overridable Function chkLH() As Boolean
        If IcTag.Status <> TagProcessStatus.Processing Then
            Return False
        Else
            Return True
        End If
    End Function
    Overridable Sub setKeyNoAfferControlFocus() 'add miaojf 2020/8/12 ver.60

    End Sub

    ''' <summary>
    ''' 设置LC的パッケージ名/製品外形
    ''' </summary>
    ''' <returns></returns>
    Overridable Function getLCPackage() As String 'add miaojf 2020/8/12 ver.60
        Return lblShape.Text
    End Function
    Overridable Function chkMoveInByAutoMode() As Boolean
        Return True
    End Function
    Protected Function chkRandCheck(lotNo As String) As Boolean
        Dim obj As New clsRandCheckHistory
        Dim dt As DataTable
        Dim rtn As Boolean = False
        dt = obj.selectRandCheckHistory(lotNo, lblProcessCD.Text, lblEquipID.Text, getInRackNo, "")
        If IsNothing(dt) OrElse dt.Rows.Count = 0 Then
            rtn = False
        Else
            rtn = True
        End If
        Return rtn
    End Function
    Private Sub txtOptNoStt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOptNoStt.TextChanged
        If txtOptNoStt.TextLength > 0 Then
            txtOptNoStt.Tag = txtOptNoStt.Text
        End If
    End Sub

    Private Sub txtLotNo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLotNo.TextChanged
        If txtLotNo.TextLength > 0 Then
            txtLotNo.Tag = txtLotNo.Text
        End If

        'ADD 苗 2018/1/27 BEGIN
        '過不足再計算（必要ある画面のみ）
        ExcessDeficiencyReCalc()
        'ADD 苗 2018/1/27 END

    End Sub

    Protected Sub txtOptNoEnd_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOptNoEnd.KeyPress
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            'PutLog(btnOptNoEnd.ToString, txtOptNoEnd.Text, "終了作業者No入力")
            ' >> 20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
            'txtOptNoEnd.Enabled = False
            strOptNoEnd = txtOptNoEnd.Text 'ADD 苗 2018/4/2
            setNextFocus(OPERATER_INPUT_TYPE.END_OPE, txtOptNoEnd)
            ' <<20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
        End If
    End Sub

    '×印が入力される度に完成数を再計算する 11/9処理停止
    Private Sub lblCrossCnt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles lblCrossCnt.TextChanged
        If String.IsNullOrEmpty(lblInputCnt.Text) OrElse
            String.IsNullOrEmpty(lblCrossCnt.Text) Then
            Exit Sub
        End If
        If m_IsHolding = OnHoldStatus.Solved And IcTag.Status = TagProcessStatus.Ready Then
            Exit Sub
        End If

        Dim iCross As Integer = CInt(lblCrossCnt.Text)
        Static Dim iDiff As Integer
        Dim iComplete = CInt(lblCompleteCnt.Text)
        iDiff += iCross - m_iLastCrossCnt - iDiff
        Try
            If iComplete - iDiff >= 0 Then
                lblCompleteCnt.Text = (iComplete - iDiff).ToString
                m_iLastCrossCnt = iCross
            ElseIf iComplete = 0 Then
            Else
                lblCrossCnt.Text = m_iLastCrossCnt.ToString
                iDiff = 0
            End If
        Catch ex As Exception
            PutLog(sender.ToString, "", ex.Message)
        End Try

    End Sub

    '不良数が入力される度に完成数を再計算する
    Private Sub lblFailedCnt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblFailedCnt.TextChanged
        If String.IsNullOrEmpty(lblInputCnt.Text) Then
            Exit Sub
        End If
        If m_IsHolding = OnHoldStatus.Solved And IcTag.Status = TagProcessStatus.Ready Then
            Exit Sub
        End If

        '不良率を再計算する（必要ある画面のみ）
        FailureRateReCalc()

        Dim iFail As Integer = CInt(lblFailedCnt.Text)
        Static Dim iDiff As Integer
        Dim iComplete As Integer = 0
        If IsNumeric(lblCompleteCnt.Text) Then
            iComplete = CInt(lblCompleteCnt.Text)
        End If
        iDiff += iFail - m_iLastFailCnt - iDiff
        Try
            If iComplete - iDiff >= 0 Then
                lblCompleteCnt.Text = (iComplete - iDiff).ToString
                m_iLastFailCnt = iFail
            ElseIf iComplete = 0 Then
            Else
                lblFailedCnt.Text = m_iLastFailCnt.ToString
                iDiff = 0
            End If
        Catch ex As Exception
            PutLog(sender.ToString, "", ex.Message)
        End Try

        '過不足再計算（必要ある画面のみ）
        ExcessDeficiencyReCalc()
    End Sub

    '不良率再計算用（必要ある画面のみ）
    Protected Overridable Sub FailureRateReCalc()

    End Sub

    Private Sub lblCompleteCnt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblCompleteCnt.TextChanged
        '過不足再計算（必要ある画面のみ）
        ExcessDeficiencyReCalc()
    End Sub
    '過不足計算用（必要ある画面のみ）
    Protected Overridable Sub ExcessDeficiencyReCalc()

    End Sub
#End Region

#Region "画面データ"
    'バーコード入力
    Protected Sub btnBarCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}03", btn.Tag.PadLeft(2, "0"c)), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)
        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = Color.Cyan
        lblData.BackColor = Color.Cyan
    End Sub

    Protected Sub btnRackCaseNoBarCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}02", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        txtData.Enabled = True
        txtData.Focus()
        'txtData.SelectAll() 'DEL MIAO 2018/8/15
        txtData.Text = String.Empty 'ADD MIAO 2018/8/15
        txtData.BackColor = Color.Cyan
        lblData.BackColor = Color.Cyan
    End Sub
    'バーコード入力完了
    Protected Sub txtData_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox)
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            txtData.Enabled = False
        End If
    End Sub

    Protected Overridable Sub txtData_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)
        '照合
        Dim szCollMsg As String
        szCollMsg = MatCollBarcode(sender, lblSys.Text, txtData, lblData)

        'If Not String.IsNullOrEmpty(szCollMsg) Then
        '    MsgBox(szCollMsg)
        'End If
        If txtData.Enabled Then
            txtData.Enabled = False
        End If

        CheckCollScore()

    End Sub


    Protected Sub txtBoxGotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtBox As TextBox = CType(sender, TextBox)
        txtBox.BackColor = Color.Cyan
        txtBox.SelectAll()
    End Sub

    Protected Sub txtBoxLostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim txtBox As TextBox = CType(sender, TextBox)
        txtBox.BackColor = Color.Yellow
        txtBox.Text = txtBox.Text.ToUpper
    End Sub

    Protected Sub lblConfirm_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim lblConfirm As Label = CType(sender, Label)
        Dim idx As Integer
        'If IsNumeric(btnConfirm.Tag) Then
        '    idx = CInt(btnConfirm.Tag) - 1
        'Else
        '    idx = CInt(btnConfirm.Tag.ToString.Substring(1)) - 1
        'End If
        idx = lblConfirm.Name.Substring(3, 2) - 1
        If IsNumeric(lblConfirm.Tag) Then
            m_iScore(idx) = CInt(lblConfirm.Tag)
        Else
            m_iScore(idx) = 0
        End If

        CheckCollScore()
    End Sub

    '「確認」ボタン
    Protected lblConfirm As Label
    Protected btnConfirm As Button
    Protected Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        btnConfirm = CType(sender, Button)
        lblConfirm = btnConfirm.Parent.Controls.Find(String.Format("lbl{0}03", btnConfirm.Tag), False)(0)
        m_DelayType = DelayType.Confirm
        Confirmed()
    End Sub

    Protected Sub Confirmed()
        If lblConfirm.Tag = 1 Then
            lblConfirm.Tag = 0
            lblConfirm.Text = String.Empty
            lblConfirm.BackColor = NORMAL_INIT_COLOR
        Else
            lblConfirm.Tag = 1
            lblConfirm.Text = getMsgStr("MSG00054")
            lblConfirm.BackColor = ENTERED_INIT_COLOR
        End If
    End Sub

    '製造条件がなければ確認不要
    Protected Sub SetOnBlank(ByVal lblSys As Label, ByVal lblData As Label, ByVal btnConfirm As Button, ByVal szMat As String)
        Me.btnConfirm = btnConfirm
        Dim idx As Integer
        If IsNumeric(btnConfirm.Tag) Then
            idx = CInt(btnConfirm.Tag) - 1
        Else
            idx = CInt(btnConfirm.Tag.ToString.Substring(1)) - 1
        End If
        If String.IsNullOrEmpty(lblSys.Text) Then
            '製造条件がない場合
            lblData.Tag = 1
            m_iScore(idx) = 1
            If lblData.Text = getMsgStr("MSG00055") Then

                Dim iSum As Integer = 0
                For Each i As Integer In m_iScore
                    iSum += i
                Next
                If iSum >= PASS_SCORE Then
                    OnCollectionDone(New EventArgs)
                Else
                    m_fColl = False
                End If
            Else
                lblData.Text = getMsgStr("MSG00055")
            End If
            btnConfirm.Enabled = False
        Else
            '製造条件がある場合
            If lblSys.Text.Equals(szMat) Then
                'If lblData.Text = "確認済み" Then
                '    lblConfirm_TextChanged(lblData, New EventArgs)
                'Else
                '    lblData.Text = "確認済み"
                'End If
                If IcTag.Status = TagProcessStatus.Ready OrElse Me.Name.Equals("frmStartCompletePQC") Then
                    'lblData.Tag = 0
                    'm_iScore(idx) = 0
                    'lblData.Text = String.Empty
                Else
                    lblData.Tag = 1
                    m_iScore(idx) = 1
                    lblData.Text = getMsgStr("MSG00054")
                End If
            ElseIf getMsgStr("MSG00054").Equals(szMat) Then
                If IcTag.Status <> TagProcessStatus.Ready OrElse Me.Name.Equals("frmStartCompletePQC") Then
                    lblData.Tag = 1
                    m_iScore(idx) = 1
                    lblData.Text = getMsgStr("MSG00054")
                    Exit Sub
                Else
                    lblData.Tag = 0
                    m_iScore(idx) = 0
                    lblData.Text = String.Empty
                End If
            Else
                lblData.Tag = 0
                m_iScore(idx) = 0
                lblData.Text = String.Empty
            End If
            btnConfirm.Enabled = True
        End If
    End Sub

    '着完時間/作業者の表示
    Overridable Sub DisplayDatePQC()
        If IsNothing(m_dtMat) OrElse m_dtMat.Rows.Count <= 0 Then
            Exit Sub
        End If

        With m_dtMat.Rows(0)
            If Not String.IsNullOrEmpty(.Item("CROSS_QTY")) Then
                lblCrossCnt.Text = .Item("CROSS_QTY")
            End If

            '着完日時/作業者
            If String.IsNullOrEmpty(.Item("BEGIN_TIME")) OrElse String.IsNullOrEmpty(.Item("BEGIN_OPT")) Then
                lblBeginTime.Text = String.Empty
            Else
                lblBeginTime.Text = CDate(.Item("BEGIN_TIME")).ToString(DATE_TIME_FORMAT)
            End If
            txtOptNoStt.Text = .Item("BEGIN_OPT")
            If String.IsNullOrEmpty(.Item("END_TIME")) OrElse String.IsNullOrEmpty(.Item("END_OPT")) Then
                lblEndTime.Text = String.Empty
            Else
                lblEndTime.Text = CDate(.Item("END_TIME")).ToString(DATE_TIME_FORMAT)
            End If
            txtOptNoEnd.Text = .Item("END_OPT")
        End With
    End Sub

    '着完時間/作業者の表示
    Overridable Sub DisplayDate()
        If IsNothing(m_dtMat) OrElse m_dtMat.Rows.Count <= 0 Then
            Exit Sub
        End If

        With m_dtMat.Rows(0)
            If IcTag.Status <> TagProcessStatus.Ready Then

                '着完日時/作業者
                If String.IsNullOrEmpty(DBNullTOblank(.Item("BEGIN_TIME"))) Then
                    lblBeginTime.Text = String.Empty
                Else
                    lblBeginTime.Text = CDate(.Item("BEGIN_TIME")).ToString(DATE_TIME_FORMAT)
                End If
                txtOptNoStt.Text = .Item("BEGIN_OPT")
                If String.IsNullOrEmpty(DBNullTOblank(.Item("END_TIME"))) Then
                    lblEndTime.Text = String.Empty
                Else
                    lblEndTime.Text = CDate(.Item("END_TIME")).ToString(DATE_TIME_FORMAT)
                End If
                txtOptNoEnd.Text = DBNullTOblank(.Item("END_OPT"))
                'ADD 2018/1/4 苗 BEING
                'X印数、X印枚数の設定
                lblCrossCnt.Text = DBNullTOblank(.Item("CROSS_QTY"))
                lblCrossPcbCnt.Text = DBNullTOblank(.Item("CROSS_FRMQTY"))
                'ADD 2018/1/4 苗 END
                'ElseIf IcTag.szLotNo.Equals(m_szLastLot) Then
                '    '同じロットの場合は作業者を表示する
                '    lblBeginTime.Text = String.Empty
                '    If txtOptNoStt.TextLength <= 0 Then
                '        txtOptNoStt.Text = txtOptNoStt.Tag
                '    End If
                '    lblEndTime.Text = String.Empty
                '    txtOptNoEnd.Clear()
            Else
                If m_ProcessStatus = ProcessStatus.Ready OrElse m_ProcessStatus = ProcessStatus.Processing Then
                    lblBeginTime.Text = String.Empty
                    txtOptNoStt.Clear()
                    lblEndTime.Text = String.Empty
                    txtOptNoStt.Clear()
                End If

            End If
        End With
        m_szLastLot = IcTag.szLotNo
    End Sub

    'ベーク工程ラックNo入力完了処理
    Protected Sub InputDonePressed()
        OnCollectionDone(New EventArgs)
    End Sub

    Overridable Sub tkl_Click(ByVal sender As Object, ByVal e As EventArgs)
        '蘇州対応　2017/04/25 maruyama@tmc
        'テンキーが複数開かないよう修正
        GetControlItem(Me, sender)

        PanelTenKey.Visible = False
        PanelTenKey_Grid.Visible = False

        Dim tkl As TenKeyLabel = CType(sender, TenKeyLabel)
        Dim pt2Screen As Point = tkl.PointToScreen(New Point(0, 0))
        '蘇州対応　2017/04/19 maruyama@tmc
        lblInput = tkl
        modTenkey.CallTenkey(tkl, Me, AddressOf TenkeyInputCompleted,
                             pt2Screen.X - Me.Left, pt2Screen.Y - Me.Top)
    End Sub

    Overridable Sub TenkeyInputCompleted()

    End Sub

    ' 蘇州対応 2017/04/18 T.Yutaro Add Start
    ' セルフチェック数量選択
    Overridable Sub lblOK_NG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim lbl As Label = CType(sender, Label)
        TimerTag.Stop()
        Select Case SelectDialog(SelectType.OK_NG, htMsgMst)
            Case DialogResult.OK
                lbl.Text = OK
                lbl.BackColor = NORMAL_INIT_COLOR
            Case DialogResult.No
                lbl.Text = NG
                lbl.BackColor = ERROR_INIT_COLOR
            Case DialogResult.Cancel
                lbl.Text = String.Empty
                lbl.BackColor = NORMAL_INIT_COLOR
        End Select
        'MatCollAll()
        '>>20170717
        If m_fIcTagUsed Then
            TimerTag.Start()
        End If
        '<<20170717
    End Sub
    ' 蘇州対応 2017/04/18 T.Yutaro Add End
#End Region

#Region "テンキー"

    Protected btnKeyAry() As System.Windows.Forms.Button
    Protected lblInput As System.Windows.Forms.Label

    Protected Sub InitTenKey()
        PanelTenKey.Visible = False
        PanelTenKey.BringToFront()
        btnKeyAry = New System.Windows.Forms.Button(9) {}
        For i = 0 To 9
            btnKeyAry(i) = CType(PanelTenKey.Controls("btn" & i), Button)
        Next
        btnC = CType(PanelTenKey.Controls("btnC"), Button)
        btnE = CType(PanelTenKey.Controls("btnE"), Button)
        For i = 0 To btnKeyAry.Length - 1
            AddHandler btnKeyAry(i).Click, AddressOf btnKeyAry_Click
        Next i
        AddHandler btnC.Click, AddressOf btnC_Click
        AddHandler btnE.Click, AddressOf btnE_Click
        AddHandler btnBar.Click, AddressOf btnbar_Click
        AddHandler btnL.Click, AddressOf btnL_Click
        AddHandler btnM.Click, AddressOf btnM_Click
        AddHandler btnW.Click, AddressOf btnW_Click
        AddHandler btnSlash.Click, AddressOf btnSlash_Click

        AddHandler lblPcbCnt.Click, AddressOf tkl_Click
        AddHandler lblCrossCnt.Click, AddressOf tkl_Click
        AddHandler lblCrossPcbCnt.Click, AddressOf tkl_Click

        'AddHandler lblCompleteCnt.MouseEnter, AddressOf TenKeyMouseEnter
        'AddHandler lblFailedCnt.MouseEnter, AddressOf TenKeyMouseEnter
        'AddHandler lblPcbCnt.MouseEnter, AddressOf TenKeyMouseEnter
        'AddHandler lblCrossCnt.MouseEnter, AddressOf TenKeyMouseEnter

        'AddHandler lblCompleteCnt.MouseLeave, AddressOf TenkeyMouseLeave
        'AddHandler lblFailedCnt.MouseLeave, AddressOf TenkeyMouseLeave
        'AddHandler lblPcbCnt.MouseLeave, AddressOf TenkeyMouseLeave
        'AddHandler lblCrossCnt.MouseLeave, AddressOf TenkeyMouseLeave
    End Sub

#Region "セル動作"
    Protected Sub CallTenKey()
        lblInput.BackColor = Color.Cyan
        Dim iDifTop As Integer = 0
        If lblInput.Parent.Name.ToUpper.StartsWith("TAB") Then
            iDifTop = lblInput.Parent.Parent.Top + lblInput.Parent.Top
        End If
        PanelTenKey.Top = btnTenKey.Bottom + 90
        PanelTenKey.Left = btnTenKey.Right + 15
        'PanelTenKey.Top = iDifTop + lblInput.Bottom + 5
        'PanelTenKey.Left = lblInput.Right - PanelTenKey.Width
        'If PanelTenKey.Left < 0 Then
        '    PanelTenKey.Left = 0
        'End If
        '蘇州対応　2017/04/26 maruyama@tmc
        'フレーム幅をはみ出さないよう修正
        If PanelTenKey.Bottom > Me.Height - SystemInformation.CaptionHeight - (SystemInformation.FrameBorderSize.Height * 2) Then
            PanelTenKey.Top = lblInput.Top - PanelTenKey.Height - 5 + iDifTop
        End If
        PanelTenKey.Visible = True

        '蘇州対応　2017/05/25 F.Gotou
        'テンキー：｢M｣、｢W｣ボタン追加
        Dim lblTag As String = lblInput.Tag.Replace(KEYPAD_CHECK, "")
        If lblTag.Equals(KEYPAD_INT) Then
            btnBar.Enabled = False
            btnDot.Enabled = False
            btnL.Enabled = False
            btnM.Enabled = False
            btnW.Enabled = False
            btnSlash.Enabled = False
        ElseIf lblTag.Equals(KEYPAD_DEC) Then
            btnBar.Enabled = False
            btnDot.Enabled = True
            btnL.Enabled = False
            btnM.Enabled = False
            btnW.Enabled = False
            btnSlash.Enabled = False
        ElseIf lblTag.Equals(KEYPAD_MW) Then
            btnBar.Enabled = False
            btnDot.Enabled = False
            btnL.Enabled = False
            btnM.Enabled = True
            btnW.Enabled = True
            btnSlash.Enabled = False
        ElseIf lblTag.Equals(KEYPAD_L) Then
            btnBar.Enabled = True
            btnDot.Enabled = False
            btnL.Enabled = True
            btnM.Enabled = False
            btnW.Enabled = False
            btnSlash.Enabled = False
        ElseIf lblTag.Equals(KEYPAD_SLASH) Then
            btnBar.Enabled = False
            btnDot.Enabled = False
            btnL.Enabled = False
            btnM.Enabled = False
            btnW.Enabled = False
            btnSlash.Enabled = True
        Else
            btnBar.Enabled = True
            btnDot.Enabled = True
            btnL.Enabled = False
            btnM.Enabled = False
            btnW.Enabled = False
            btnSlash.Enabled = False
        End If

        '蘇州対応　2017/06/12 maruyama@tmc
        TenkeyText.Text = lblInput.Text
        TenkeyText.Focus()
        'TenkeyText.Select(TenkeyText.Text.Length, 0)'DEL 苗 2018/1/30
        TenkeyText.SelectAll() 'ADD 苗 2018/1/30 BEGIN
    End Sub

    Protected Sub TenKeyClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '蘇州対応　2017/04/25 maruyama@tmc
        'テンキーが複数開かないよう修正
        GetControlItem(Me, sender)

        PanelTenKey_Grid.Visible = False

        lblInput = CType(sender, Label)
        m_DelayType = DelayType.Tenkey
        CallTenKey()
    End Sub

    Protected Sub TenKeyMouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
        CType(sender, Label).BackColor = Color.DodgerBlue
    End Sub

    Protected Sub TenkeyMouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)
        CType(sender, Label).BackColor = TENKEY_INIT_COLOR
        If PanelTenKey.Visible Then
            lblInput.BackColor = Color.Cyan
        End If
    End Sub

#End Region

#Region "キー入力処理"
    '******************************************************************************
    '*  キー入力処理
    '******************************************************************************
    Protected Sub btnKeyAry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btnKey As Button = CType(sender, Button)
        Dim strKey As String = btnKey.Text
        'If TenkeyText.Text.Equals("0") Then
        '    TenkeyText.Text = strKey
        'Else
        If TenkeyText.Text.Length >= 7 Then
            Exit Sub
        End If
        'UPD 苗 2018/1/30 BEGIN
        If TenkeyText.SelectionLength > 0 Then
            TenkeyText.Text = strKey
        Else
            TenkeyText.Text &= strKey
        End If
        'UPD 苗 2018/1/30 END
        'End If
    End Sub

    Private Sub btnDot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
        Dim chrArr() As Char = TenkeyText.Text.ToCharArray
        For Each chara As Char In chrArr
            If chara = CChar(".") Then
                Exit Sub
            End If
        Next
        TenkeyText.Text &= "."
    End Sub

    Protected Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        TenkeyText.Text = String.Empty

        '蘇州対応　2017/05/25 F.Gotou
        ' テンキー：｢M｣、｢W｣ボタン追加
        'If btnL.Visible Or btnM.Visible Or btnW.Visible Then
        '    TenkeyText.Text = String.Empty
        'Else
        '    TenkeyText.Text = "0"
        'End If
    End Sub

    Protected Sub btnbar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText.Text &= "-"
    End Sub

    Protected Sub btnL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText.Text &= "L"
    End Sub

    '蘇州対応　2017/05/25 F.Gotou
    ' テンキー：｢M｣、｢W｣ボタン追加
    Protected Sub btnM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText.Text = "M"
    End Sub

    Protected Sub btnW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText.Text = "W"
    End Sub

    '「/」ボタン追加
    Protected Sub btnSlash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText.Text &= "/"
    End Sub

    '>>20180116 佐川
    Protected Overridable Sub btnE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '>>20180116 佐川
        lblInput.Text = CInt(IIf(TenkeyText.Text = "", "0", TenkeyText.Text))  'UPD 苗 2018/1/30 BEGIN

        PanelTenKey.Visible = False
        TenKeyDone()

        Dim lblSender As System.Object = lblInput
        If lblSender.Tag.IndexOf(KEYPAD_CHECK) >= 0 Then
            MatCollTenkey(lblSender)
        Else
            lblInput.BackColor = ENTERED_INIT_COLOR
        End If
    End Sub

    Overridable Sub TenKeyDone()

    End Sub

    Protected Function CheckNum() As Boolean
        If IsNumeric(lblInput.Text) Then
            CheckNum = True
        Else
            CheckNum = False
        End If
    End Function
#End Region

#End Region
#End Region

#Region "制御・動作"

#Region "画面状態"
    '画面状態変更
    Public Event ProcessStatusChanged As EventHandler
    Protected Overridable Sub OnProcessStatusChanged(ByVal sender As Object)
        RaiseEvent ProcessStatusChanged(sender, New EventArgs)
    End Sub

    Public Sub convertProcessStatus()
        If IcTag.Status = TagProcessStatus.Ready Then
            m_ProcessStatus = ProcessStatus.Ready
        ElseIf IcTag.Status = TagProcessStatus.Processing Then
            m_ProcessStatus = ProcessStatus.Processing
        ElseIf IcTag.Status = TagProcessStatus.ManufComplete Then
            m_ProcessStatus = ProcessStatus.ManufComplete
        End If
    End Sub

    Protected Sub ProcessStatusChange(ByVal sender As Object, ByVal e As EventArgs) Handles Me.ProcessStatusChanged

        If m_ProcessStatus = ProcessStatus.Ready Or
            m_ProcessStatus = ProcessStatus.TagSet Or
            m_ProcessStatus = ProcessStatus.Processing Or
            m_ProcessStatus = ProcessStatus.ManufComplete Then

            m_PerProcessStatus = m_ProcessStatus  'エラー前の状態を保存する　ADD 苗 2018/1/26
        End If
        'ADD 苗 2018/3/7 BEGIN
        If IsBsiteMulti() And m_ProcessStatus = ProcessStatus.Preprocess Then
            m_PerProcessStatus = ProcessStatus.TagSet
        End If
        'ADD 苗 2018/3/7 END
        Select Case m_ProcessStatus
            Case ProcessStatus.Ready
                btnStart.Text = getMsgStr("MSG00118")
                btnStart.BackColor = Drawing.SystemColors.Control
                LastTag = New TagData

                btnManufComp.Enabled = False
                btnTotalComp.Enabled = False
                btnErrInput.Enabled = False
                btnCancel.Enabled = False

                txtOptNoStt.Clear()
                txtOptNoEnd.Clear()
                lblBeginTime.Text = String.Empty
                lblEndTime.Text = String.Empty
                'If Not IsNothing(m_iScore) AndAlso m_iScore.Length > 1 AndAlso m_fColl Then
                txtOptNoStt.Clear()
                txtOptNoEnd.Clear()
                If IsBsiteMulti() Then
                    m_ProcessStatus = ProcessStatus.TagSet
                Else
                    m_dtMat.Clear()
                End If
            Case ProcessStatus.TagSet
                Select Case IcTag.Status
                    Case TagProcessStatus.Ready
                        lblBeginTime.Text = String.Empty
                        lblEndTime.Text = String.Empty

                        btnManufComp.Enabled = False
                        btnTotalComp.Enabled = False
                        btnErrInput.Enabled = False
                        btnCancel.Enabled = False

                        'End If
                        'If Not m_fColl OrElse txtOptNoStt.TextLength <= 0 OrElse m_IsHolding = OnHoldStatus.Solved Then

                        btnStart.Text = getMsgStr("MSG00118")
                        btnStart.BackColor = Drawing.SystemColors.Control
                        'End If

                        GetData()
                        If IsBsiteMulti() Then
                            convertProcessStatus()
                            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                        End If
                        HoldFrame()
                    Case TagProcessStatus.Processing
                        GetData()
                        If IsBsiteMulti() Then
                            convertProcessStatus()
                        Else
                            m_ProcessStatus = ProcessStatus.Processing
                        End If
                        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                        HoldFrame()
                        Exit Sub
                    Case TagProcessStatus.ManufComplete
                        GetData()
                        'ADD 苗 2018/1/7 BEGIN
                        Dim strMutliStatus = getMutliStatus()
                        If IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempProcessing Then
                            m_ProcessStatus = ProcessStatus.TempProcessing

                            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                            Exit Sub
                        ElseIf IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempComplete Then
                            m_ProcessStatus = ProcessStatus.TempComplete
                            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                            Exit Sub
                        End If
                        'ADD 苗 2018/1/7 END
                        If IsBsiteMulti() Then
                            convertProcessStatus()
                        Else
                            m_ProcessStatus = ProcessStatus.ManufComplete
                        End If
                        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                        HoldFrame()
                        Exit Sub

                End Select
            Case ProcessStatus.Preprocess
                '工程CDが合わないと着工開始しない
                If Not m_fProcessCheck Then
                    m_ProcessStatus = ProcessStatus.Ready
                    Exit Select
                End If
                '新着工の場合は着工開始処理を行う
                If IcTag.Status = TagProcessStatus.Ready Then
                    If Not (IsNothing(IcTag.szUID) And IsNothing(LastTag.szUID)) Then
                        'Not String.IsNullOrEmpty(lblLotNo.Text) Then
                        If AutoManualMode = 0 Then
                            If m_WARNING = "0" Then
                                WorkStart()
                            Else
                                If Command_LD_Received = True Then
                                    WorkStart()
                                Else
                                    doLC()
                                    'Dim tmpLotNo As String = txtLotNo.Text
                                    'Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)
                                    'Dim pkgValue As String = getLCPackage()
                                    'If m_EquipInstPattern <> "00" Then
                                    '    If pkgValue = "too Much" Then
                                    '        setCheckInfo("程序被设定多条，请确认。")
                                    '        Exit Sub
                                    '    End If
                                    '    If pkgValue = "" Then
                                    '        setCheckInfo("没有设定程序，请确认。")
                                    '        Exit Sub
                                    '    End If
                                    'End If
                                    'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "", lblInputFrm.Text, pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
                                    '    Command_LD_Received = False
                                    '    ShowCommandWaiting()
                                End If
                            End If

                        End If
                        If AutoManualMode = 1 Then
                            WorkStart()
                        End If
                    Else
                        TimerBegin.Start()
                    End If
                Else
                End If
            Case ProcessStatus.Processing
                m_ProcessStatus = ProcessStatus.Ready
                Dim strMutliStatus = getMutliStatus()
                If IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempProcessing Then
                    m_ProcessStatus = ProcessStatus.TempProcessing
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                ElseIf IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempComplete Then
                    m_ProcessStatus = ProcessStatus.TempComplete
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                Else
                    btnStart.Text = getMsgStr("MSG00119")
                    btnStart.BackColor = Color.Lime
                    '着工制御ボタンを有効化
                    Select Case m_CompleteType
                        Case CompleteType.ManufComplete
                            btnManufComp.Enabled = False 'UPD MIAOJF 2020/10/28 
                            btnTotalComp.Enabled = False
                        Case CompleteType.TotalComplete
                            btnManufComp.Enabled = False
                            btnTotalComp.Enabled = True
                        Case CompleteType.All
                            btnManufComp.Enabled = False 'UPD MIAOJF 2020/10/28 
                            btnTotalComp.Enabled = True
                    End Select
                    btnErrInput.Enabled = True
                    btnCancel.Enabled = True
                End If

                'getPingzhongByDB()

                'BeginTime
            Case ProcessStatus.ManufComplete
                'ADD 苗 2018/1/7 BEGIN
                Dim strMutliStatus = getMutliStatus()
                If IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempProcessing Then
                    m_ProcessStatus = ProcessStatus.TempProcessing
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                ElseIf IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempComplete Then
                    m_ProcessStatus = ProcessStatus.TempComplete
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                Else
                    'ADD 苗 2018/1/7 END
                    btnStart.Text = getMsgStr("MSG00120")
                    btnStart.BackColor = Drawing.SystemColors.Info

                    btnManufComp.Enabled = False
                    If m_CompleteType = CompleteType.All OrElse m_CompleteType = CompleteType.TotalComplete Then
                        btnTotalComp.Enabled = True
                    Else
                        btnTotalComp.Enabled = False
                    End If
                    btnErrInput.Enabled = True
                    btnCancel.Enabled = False

                End If
            Case ProcessStatus.TotalComplete
                'ADD 苗 2018/1/7 BEGIN
                Dim strMutliStatus = getMutliStatus()
                If IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempProcessing AndAlso mMultiExecCheck = False Then
                    m_ProcessStatus = ProcessStatus.TempProcessing
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                ElseIf IsBsiteMulti() = True AndAlso strMutliStatus = ProcessStatus.TempComplete AndAlso mMultiExecCheck = False Then
                    m_ProcessStatus = ProcessStatus.TempComplete
                    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    Exit Sub
                Else
                    'ADD 苗 2018/1/7 END
                    btnStart.Text = getMsgStr("MSG00121")
                    btnStart.BackColor = Color.Cyan

                    btnManufComp.Enabled = False
                    btnTotalComp.Enabled = False
                    btnErrInput.Enabled = False
                    btnCancel.Enabled = False
                End If
                'EndTime
            Case ProcessStatus.Canceled
                btnStart.Text = getMsgStr("MSG00122")
                btnStart.BackColor = Color.LightCoral

                btnManufComp.Enabled = False
                btnTotalComp.Enabled = False
                btnErrInput.Enabled = False
                btnCancel.Enabled = False
            Case ProcessStatus.Failed
                btnStart.Text = getMsgStr("MSG00123")
                btnStart.BackColor = Color.LightCoral
                'ADD 苗 2018/1/26 BEGIN 前の状態を戻り
                'btnManufComp.Enabled = False
                'btnTotalComp.Enabled = False
                'btnErrInput.Enabled = False
                'btnCancel.Enabled = False
                '前の状態を戻り
                m_ProcessStatus = m_PerProcessStatus
                'ADD 苗 2018/1/26 END
            Case ProcessStatus.Hold
                btnStart.Text = getMsgStr("MSG00124")
                btnStart.BackColor = ERROR_INIT_COLOR
                Me.Enabled = False
                'ADD 苗 2018/1/7 BEGIN
            Case ProcessStatus.TempProcessing
                btnStart.Text = getMsgStr("MSG10013")
                btnStart.BackColor = Color.Lime

                btnManufComp.Enabled = False
                btnTotalComp.Enabled = True

                btnErrInput.Enabled = True
                btnCancel.Enabled = True
                'm_ProcessStatus = ProcessStatus.TagSet
                'IcTag.Status = TagProcessStatus.Processing
            Case ProcessStatus.TempComplete
                btnManufComp.Enabled = False
                btnTotalComp.Enabled = False
                btnErrInput.Enabled = False
                btnCancel.Enabled = False

                btnStart.Text = getMsgStr("MSG10014")
                btnStart.BackColor = Color.Cyan

                txtOptNoEnd.Clear()
                lblBeginTime.Text = String.Empty
                lblEndTime.Text = String.Empty
                IcTag.Status = TagProcessStatus.ManufComplete
                'm_ProcessStatus = ProcessStatus.Ready

                'ADD 苗 2018/1/7 END
        End Select

        '工程CDが合わないと着工完了できない
        If Not m_fProcessCheck Then
            btnManufComp.Enabled = False
            btnTotalComp.Enabled = False
            btnErrInput.Enabled = False
            btnCancel.Enabled = False
        Else

            If m_IsHolding <> OnHoldStatus.OnHold Then
                '>>20170717
                If m_fIcTagUsed Then
                    TimerTag.Start()
                End If
                '<<20170717
            End If
        End If
        '>>20180122 佐川
        'If markchart.Length > 0 Then
        '>> 20180227 佐川 着工待ちはマーク図押下不可対応
        'If Not m_ProcessStatus.Equals(ProcessStatus.Ready) Then
        '    Button1.Enabled = True
        'Else
        '    Button1.Enabled = False
        'End If
        '<< 20180227 佐川 着工待ちはマーク図押下不可対応
        'End If
        '<<20180122 佐川
        ConfScreenItem()
    End Sub

    Protected Overridable Sub getPingzhongByDB()

    End Sub


    Private Sub HoldFrame()
        If IcTag.OnHoldSt = OnHoldStatus.OnHold Then
            m_ProcessStatus = ProcessStatus.Hold
            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If
    End Sub

    Private Sub TimerBegin_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TimerBegin.Tick
        TimerBegin.Stop()
        If Not (IsNothing(IcTag.szUID) And IsNothing(LastTag.szUID)) And IcTag.Status <> TagProcessStatus.Processing Then
            'Not String.IsNullOrEmpty(lblLotNo.Text) Then
            If AutoManualMode = 0 Then
                If Command_LD_Received = True Then
                    WorkStart()
                Else
                    doLC()
                    'Dim tmpLotNo As String = txtLotNo.Text
                    'Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)
                    'Dim pkgValue As String = getLCPackage()
                    'If m_EquipInstPattern <> "00" Then
                    '    If pkgValue = "too Much" Then
                    '        setCheckInfo("程序被设定多条，请确认。")
                    '        Exit Sub
                    '    End If
                    '    If pkgValue = "" Then
                    '        setCheckInfo("没有设定程序，请确认。")
                    '        Exit Sub
                    '    End If
                    'End If
                    'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "", lblInputFrm.Text, pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
                    '    Command_LD_Received = False
                    '    ShowCommandWaiting()
                End If
            End If
            If AutoManualMode = 1 Then
                WorkStart()
            End If
        Else
            m_ProcessStatus = ProcessStatus.Ready
        End If
    End Sub

    Private Sub ClearHeader()
        ClearCollCells()
        lblkindNm.Text = String.Empty
        lblLotNo.Text = String.Empty
        lblDiffLotNo.Text = String.Empty
        lblPbLayout.Text = String.Empty
        lblShape.Text = String.Empty
        lblInputCnt.Text = String.Empty
        lblInputFrm.Text = String.Empty
        lblInputCross.Text = String.Empty
        lblInputCrossFrm.Text = String.Empty
        lblCompleteCnt.Text = String.Empty
        lblFailedCnt.Text = String.Empty
        lblPcbCnt.Text = String.Empty
        lblCrossCnt.Text = String.Empty
        lblCrossPcbCnt.Text = String.Empty
        lblNextProcs.Text = String.Empty

    End Sub

    '新設置したタグでデータを取得する
    Private Sub GetData()

        TimerTag.Stop()

        '>>20171012 兪
        ShowBsiteWaiting()
        '>>20180110 兪
        'タグデータをB-siteと同期する
        'SyncLotInfo()
        '<<20180110 兪

        'ICタグでデータを取得
        GetDataByIcTag()

        If m_MoveInCheck = False Then
            lblWait.Visible = False
            Me.Enabled = True
            Me.Cursor = Cursors.Default

            'm_MoveInCheck = True
            Exit Sub
        End If

        '不良カテゴリを取得
        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
            getFrameInfo()
            setErrorInfoOnlyNG()

        Else
            GetDefectCata()
        End If

        lblWait.Visible = False
        Me.Enabled = True
        Me.Cursor = Cursors.Default
        '<<20171012 兪

        '>>20170717
        If m_fIcTagUsed Then
            TimerTag.Start()
        End If
        '<<20170717

    End Sub

    '画面項目の表示切替
    Overridable Sub ConfScreenItem()

    End Sub

#End Region

#Region "画面動作"

    '着工開始処理
    Overridable Sub WorkStart()
        'ADD MIAO 2020/1/30
        If Command_LD_Received = False Then
            PutLog(Me.ToString, "LD ININ", "Command_LD_Received==" & Command_LD_Received)
            Exit Sub
        End If
        Try
            'PQC CHECK
            If chkMatChanged() Then
                chkPQC()
            End If
        Catch ex As Exception
            setCheckInfo("PQC接口连接失败。")
        End Try


        'ADD MIAO 2018/11/08 Begin
        Dim chkM As String = ""
        chkM = chkMonitoringAPP()
        If chkM <> "0" Then
            'If MsgBox(getMsgStr("MSG10051"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'UPD MIAO 2019/1/9
            MsgBox(getMsgStr("MSG10051", chkM)）
            Exit Sub
        End If
        'ADD MIAO 2018/11/08 END
        'ADD MIAO 2019/10/1 Begin
        If chkSumSHOTValue() = False Then
            Exit Sub
        End If
        'ADD MIAO 2019/10/01 END
        '>>20180113 佐川
        'GroupKey対応初期化
        execCount = 0
        frmGroupKeyResultMsg = Nothing
        '<<20180113 佐川

        '着工開始のコマンドの送信
        m_CmdType = CommandType.JI
        '>>20180111 兪
        If inputLotType = INPUTLOTTYPE_DIFF Then
            '>>20180115 佐川
            Dim firstIcTag As New TagData
            Dim firstLotNo As String = ""
            '<<20180115 佐川

            '>> 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            For Each tagData In GroupID.Select(Function(item, i) New With {item, i})
                IcTag = tagData.item
                lotNo = tagData.item.szLotNo

                If IcTag.iInput <> 0 Then '2021/8/23 小Lot统合 mjf 

                    '>>20180111 佐川
                    SendCommand(m_CmdType, False, IcTag)
                End If '2021/8/23 小Lot统合 mjf 
                '<<20180111 佐川
                If execCount = 0 Then
                    '１件目のステータス変更後のデータを保持
                    firstIcTag = IcTag
                    firstLotNo = lotNo
                End If

                '>>20180112 佐川
                execCount += 1
                '<<20180112 佐川
                GroupID(tagData.i) = IcTag
            Next
            '<< 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
            '>>20180115 佐川
            IcTag = firstIcTag
            lotNo = firstLotNo
            '<<20180115 佐川
        Else
            PutLog(Me.ToString, "LD ININ ", "DO SendCOmmand BEGIN")
            '>>20180111 佐川
            If IcTag.iInput <> 0 Then '2021/8/23 小Lot统合 mjf 
                SendCommand(m_CmdType, False, IcTag)
            End If
            '<<20180111 佐川
            PutLog(Me.ToString, "LD ININ ", "DO SendCOmmand END")

        End If
        '<<20180111 兪

        If RandCheckFLAG Then
            '抜取り検査処理
            randCheck() 'ADD MIAOJF 2019/12/30
        End If
    End Sub

    Protected Overridable Sub randCheck()
        Dim dtRCMST As DataTable '車品DataTable
        Dim dtRecords As DataTable
        Dim objRCRecords As New clsRandCheckRecords '抜取検査の記録表
        Dim Main_ProdName As String = "" '品名
        Dim Main_PKG As String = "" 'PKG名
        Dim Main_CurrentNum As String = 0 'ラック数或いはLOT数
        Dim Main_CarFlg As String = ""
        Dim Main_ProcName As String = Label1.Text.Trim
        Main_ProdName = lblkindNm.Text
        Main_PKG = lblShape.Text.Split("-")(0).ToString
        dtRCMST = getRandCheckRuleData(Main_ProcName, Main_ProdName, Main_PKG, CAR, "")

        If dtRCMST.Rows.Count > 0 Then '車品の処理
            Main_CarFlg = CAR
            If dtRCMST.Rows(0)("CheckType") = "0" Then 'ラック数
                Main_CurrentNum = getRackCount()
            ElseIf dtRCMST.Rows(0)("CheckType") = "1" Then 'LOT数
                Main_CurrentNum = 1
            End If

        ElseIf dtRCMST.Rows.Count = 0 Then '民用品の処理
            Main_CarFlg = CIVIL
            Select Case Main_ProcName
                Case "DB"
                    Main_ProdName = ""
                    Main_PKG = ""
                Case "WB"
                    'Main_ProdName = lblPbLayout.Text
                    Main_PKG = ""
                Case "MD"
                    Main_ProdName = ""
                    'Main_PKG = lblShape.Text.Split("-")(0).ToString
            End Select
            '設備別設定内容がありましたら、設備別の設定値を利用する。
            dtRCMST = getRandCheckRuleData(Main_ProcName, Main_ProdName, Main_PKG, Main_CarFlg, lblEquipID.Text)

            '設備別設定内容がなければ、共通の設定値を利用する。
            If dtRCMST.Rows.Count = 0 Then
                dtRCMST = getRandCheckRuleData(Main_ProcName, Main_ProdName, Main_PKG, Main_CarFlg, "")
            End If

        End If

        'ルールなければ、A工程skip要
        If dtRCMST.Rows.Count = 0 Then
            Exit Sub
        End If
        If IsDBNull(dtRCMST.Rows(0)("PKG")) = False Then
            Main_PKG = dtRCMST.Rows(0)("PKG")
        End If
        '区分で個数をセットする
        If dtRCMST.Rows(0)("CheckType") = "0" Then 'ラック数
            Main_CurrentNum = getRackCount()
        ElseIf dtRCMST.Rows(0)("CheckType") = "1" Then 'LOT数
            Main_CurrentNum = 1
        Else
            Main_CurrentNum = 0
        End If

        '設備の記録を取得する
        dtRecords = objRCRecords.selectRecords(lblEquipID.Text, "", "") 'Main_ProdName, Main_PKG)
        Dim recordsCountNum As Integer = 0
        If dtRecords.Rows.Count > 0 Then
            '取得した記録の品名とPKGとマスタの品名とPKGと同じの場合
            If DBNullTOblank(dtRecords.Rows(0)("ProdName")) = Main_ProdName And DBNullTOblank(dtRecords.Rows(0)("PKG")) = Main_PKG Then
                recordsCountNum = dtRecords.Rows(0)("CountNum")
            Else
                '上記以外の場合
                '記録クリア
                objRCRecords.deleteRecords(lblEquipID.Text)
                'dtRecordsをクリア
                dtRecords = New DataTable
            End If
        End If
        '---------------------------------------------------------
        'DB民用品
        If Main_ProcName = "DB" And Main_CarFlg = CIVIL Then
            If isLastOneLot() Then
                doRandCheck(dtRCMST, dtRecords)
            Else
                Exit Sub
            End If

        Else 'MD,WB民用品＆DB,WB,DB車品
            '記録の個数＋今回の個数＞＝マスタのValue
            If isLastOneLot() Then
                If recordsCountNum + Main_CurrentNum >= dtRCMST.Rows(0)("CheckValue") Then
                    doRandCheck(dtRCMST, dtRecords)
                Else
                    dontRandCheck(dtRecords, Main_ProdName, Main_PKG, Main_CurrentNum)
                End If
            End If
        End If
        '---------------------------------------------------------


    End Sub
    ''' <summary>
    ''' 抜取検査履歴の作成
    ''' </summary>
    ''' <param name="dtmst">抜取検査ルール</param>
    ''' <param name="dtRecords">設備別の記録</param>
    Protected Overridable Sub doRandCheck(dtmst As DataTable, dtRecords As DataTable)
        '抜取検査履歴追加
        ''MSTの抜取検査数がある場合：履歴追加
        ''MSTの抜取検査数がない場合：AQLテーブルでAQLの抜取検査数を検索し、履歴追加
        '記録削除
        'A工程着工要
    End Sub

    ''' <summary>
    '''  抜取検査しない場合の処理
    ''' </summary>
    ''' <param name="dtRecords">記録データ</param>
    ''' <param name="ProdName">品名</param>
    ''' <param name="PKG">PKG</param>
    ''' <param name="countNum">個数</param>
    Protected Overridable Sub dontRandCheck(dtRecords As DataTable, ProdName As String, PKG As String, countNum As Integer)
        '記録がある場合修正、ない場合の追加
        'A工程skip要
    End Sub
    ''' <summary>
    ''' GroupID下の最後の組立Lotが判断
    ''' </summary>
    ''' <returns>TRUE：最後の組立LOT、FALSE：最後の組立LOTではない</returns>
    Protected Overridable Function isLastOneLot() As Boolean
        Return True
    End Function
    Protected Overridable Function getRackCount() As Integer
        Return 1
    End Function
    Protected Overridable Sub updateRCRackID()
    End Sub


    Private Function getRandCheckRuleData(ProcCD As String, ProdName As String, PKG As String, CarFlg As String, EquipNo As String) As DataTable
        Dim dt As DataTable
        Dim objMstRule As New clsDBMSTRandCheck
        dt = objMstRule.selectRuleForRC(ProcCD, ProdName, PKG, CarFlg, EquipNo)
        Return dt
    End Function
    Overridable Sub setRandCheckInfo(Str As String)
        Me.pnlCheckInfo.Visible = True
        Me.pnlCheckInfo.BringToFront()

        txtChkInfo.Text = txtChkInfo.Text & getMsgStr("MSG10058", Str) & vbCrLf
    End Sub

    Protected Sub setCheckInfo(str As String)
        Me.pnlCheckInfo.Visible = True
        Me.pnlCheckInfo.BringToFront()

        If txtChkInfo.Text.Contains(str) Then Exit Sub

        txtChkInfo.Text = str & vbCrLf

        If LNNG_MSG_FLG = True And reconfirmNBIGS = False Then
            'If AutoManualMode = 0 Then

            PutLog(Me.ToString, COMMAND_IT, "NG")
            'ITコマンド
            sendResponseCommand(COMMAND_IT, COMMAND_NG)
            'Else
            '    Dim szCmdToSend As String = ""

            '    With IcTag
            '        'Atlasサーバ送信
            '        szCmdToSend = String.Format(CMD_NJ, .szLotNo, lblProcessCD.Text, lblEquipID.Text, NG)
            '    End With
            '    clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)
            'End If
        End If

    End Sub
    ''' <summary>
    ''' 累計SHOT数と規格数のチェック
    ''' </summary>
    ''' <returns>判断結果：True着工可、False着工不可</returns>
    Protected Overridable Function chkSumSHOTValue() As Boolean
        Return True
    End Function
    'ADD MIAO 2018/11/08 Begin
    'Monitoring実行中かチェック
    Private Function chkMonitoringAPP() As String

        Dim status As String = "0"

        status = m_cEquipMat.getEquipStatus(g_CURRENT_EQUIP_ID)
        Return status

    End Function
    'ADD MIAO 2018/11/08 END

#Region "DEL 2018/7/12"
    '    ' ベーク着工処理
    '    Protected Sub bakeWorkStart(ByRef dtBake As DataTable)
    '        Dim inParam As New InSiteWebService.InMoveInBake
    '        inParam.Employee = txtOptNoStt.Text
    '        inParam.Machine = g_EQUIP_NO         '装置No
    '        Dim lotA As String() = New String() {}
    '        Dim lotCnt As Integer = 0
    '        Dim checkErrorLotCnt = 0
    '        Dim clientProcCd As String = GetBsiteClientString()
    '        For Each drLot As DataRow In dtBake.Rows
    '            If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '                ReDim Preserve lotA(lotCnt)
    '                lotA(lotCnt) = drLot("LOT_NO")
    '                lotCnt += 1
    '            End If
    '        Next

    '#Region "DEL 2018/4/13"
    '        ''ADD 苗 2018/4/12 BEGIN
    '        'inParam.Lot = lotA 'UPD 苗 2018/3/29 
    '        'Dim outParamCheck As InSiteWebService.OutMoveInBake = MoveInBakeService_Check(inParam, clientProcCd)
    '        'If outParamCheck.Header IsNot Nothing Then
    '        '    outHeader = outParamCheck.Header
    '        '    Select Case outParamCheck.Header.Status
    '        '        Case STS_SUCCESS
    '        '            '続きます
    '        '        Case Else
    '        '            For Each drLot As DataRow In dtBake.Rows
    '        '                If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '        '                    drLot("RESULT") = "OK"
    '        '                    For Each lotno As String In outParamCheck.Header.ResultLot
    '        '                        If drLot("LOT_NO").ToString.Equals(lotno) Then
    '        '                            drLot("RESULT") = "NG"
    '        '                            Exit For
    '        '                        End If
    '        '                    Next
    '        '                End If
    '        '            Next
    '        '            If outParamCheck.Header.Status = STS_ERROR Then
    '        '                ShowBsiteResult(NG)
    '        '            End If
    '        '            Exit Sub

    '        '    End Select
    '        'End If
    '        'ADD 苗 2018/4/12 END
    '#End Region

    '        Dim outParamCheck As New InSiteWebService.OutMoveInBake 'ADD 苗 2018/4/13
    '        If bakeStartFinishCheck(1, inParam, outParamCheck, lotCnt, dtBake, lotA) = True Then 'ADD 苗 2018/4/13


    '            'ADD 苗 2018/3/29 BEGIN
    '            Dim intModedNum As Integer = Math.Ceiling(lotCnt / m_bakeNum)

    '            Dim lotB As String() = New String() {}


    '            For i As Integer = 0 To intModedNum - 1
    '                Dim intTempNum As Integer = i * m_bakeNum
    '                If i < intModedNum - 1 Then
    '                    'Erase lotB
    '                    ReDim lotB(m_bakeNum - 1)
    '                Else
    '                    ' Erase lotB
    '                    ReDim lotB(lotCnt - intTempNum - 1)
    '                End If

    '                For intTempIndex As Integer = 0 To m_bakeNum - 1
    '                    If intTempNum + intTempIndex < lotCnt Then
    '                        lotB(intTempIndex) = lotA(intTempNum + intTempIndex)
    '                    End If
    '                Next
    '                'ADD 苗 2018/3/29 END
    '                '着工処理
    '                inParam.Lot = lotB 'UPD 苗 2018/3/29 
    '                ShowBsiteWaiting()
    '                Dim outParam As InSiteWebService.OutMoveInBake = MoveInBakeService_Execute(inParam, clientProcCd)
    '                lblWait.Visible = False
    '                Me.Enabled = True
    '                '戻り情報を保持
    '                outHeader = outParam.Header

    '                If outParam.Header IsNot Nothing Then
    '                    Select Case outParam.Header.Status
    '                        Case STS_SUCCESS
    '                            For Each drLot As DataRow In dtBake.Rows
    '                                drLot("RESULT") = "OK"
    '                            Next
    '                            '>>20180328 大賀 No122 DBサーバ時刻を使用する
    '                            'If Not DateTime.TryParse(outParam.Header.LotInf.LastActivityDate, serverTime) Then
    '                            '    serverTime = Now()
    '                            'End If
    '                            serverTime = m_cData.GetServerTime()
    '                            '<<20180328 大賀 No122 DBサーバ時刻を使用する
    '                            ShowBsiteResult(OK)
    '                            'SaveEquipMat(serverTime) 'DEL 苗 2018/4/2

    '                        Case Else
    '                            For Each drLot As DataRow In dtBake.Rows
    '                                If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '                                    drLot("RESULT") = "OK"
    '                                    For Each lotno As String In outParam.Header.ResultLot
    '                                        If drLot("LOT_NO").ToString.Equals(lotno) Then
    '                                            drLot("RESULT") = "NG"
    '                                            Exit For
    '                                        End If
    '                                    Next
    '                                End If
    '                            Next
    '                            If outParam.Header.Status = STS_ERROR Then
    '                                ShowBsiteResult(NG)
    '                            End If
    '                            Exit Sub 'ADD 苗 2018/4/12 
    '                    End Select
    '                End If
    '            Next
    '            SaveEquipMat(serverTime) 'ADD 苗 2018/4/2
    '        End If
    '    End Sub
#End Region


#Region "ADD 2018/7/12 "
    ' ベーク着工処理
    Protected Sub bakeWorkStart(ByRef dtBake As DataTable)
        Dim inParam As New InSiteWebService.InMoveInBake
        inParam.Employee = txtOptNoStt.Text
        inParam.Machine = g_EQUIP_NO         '装置No
        Dim lotA As String() = New String() {}
        Dim lotCnt As Integer = 0
        Dim checkErrorLotCnt = 0
        Dim clientProcCd As String = GetBsiteClientString()

        'ADD MIAO 2018/11/08 Begin
        Dim chkM As String = ""
        chkM = chkMonitoringAPP()
        If chkM <> "0" Then
            'If MsgBox(getMsgStr("MSG10051"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'UPD MIAO 2019/1/9
            MsgBox(getMsgStr("MSG10051", chkM)）
            Exit Sub
        End If
        'ADD MIAO 2018/11/08 END

        For Each drLot As DataRow In dtBake.Rows
            If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
                ReDim Preserve lotA(lotCnt)
                lotA(lotCnt) = drLot("LOT_NO")
                lotCnt += 1
            End If
        Next

        '着工処理
        inParam.Lot = lotA
        ShowBsiteWaiting()
        Dim outParam As InSiteWebService.OutMoveInBake = MoveInBakeService_Execute(inParam, clientProcCd)
        lblWait.Visible = False
        Me.Enabled = True
        '戻り情報を保持
        outHeader = outParam.Header

        If outParam.Header IsNot Nothing Then
            Select Case outParam.Header.Status
                Case STS_SUCCESS
                    For Each drLot As DataRow In dtBake.Rows
                        drLot("RESULT") = "OK"
                    Next
                    '>>20180328 大賀 No122 DBサーバ時刻を使用する
                    'If Not DateTime.TryParse(outParam.Header.LotInf.LastActivityDate, serverTime) Then
                    '    serverTime = Now()
                    'End If
                    serverTime = m_cData.GetServerTime()
                    '<<20180328 大賀 No122 DBサーバ時刻を使用する
                    ShowBsiteResult(OK)
                    SaveEquipMat(serverTime)
                Case Else
                    For Each drLot As DataRow In dtBake.Rows
                        If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
                            drLot("RESULT") = "OK"
                            For Each lotno As String In outParam.Header.ResultLot
                                If drLot("LOT_NO").ToString.Equals(lotno) Then
                                    drLot("RESULT") = "NG"
                                    Exit For
                                End If
                            Next
                        End If
                    Next
                    If outParam.Header.Status = STS_ERROR Then
                        ShowBsiteResult(NG)
                    End If
            End Select
        End If
    End Sub
#End Region
#Region "DEL 2018/7/12 "
    '    ' ベーク完成処理
    '    Protected Sub bakeWorkFinish(ByRef dtBake As DataTable)
    '        Dim inParam As New InSiteWebService.InMoveStdBake
    '        inParam.Employee = txtOptNoEnd.Text
    '        inParam.Machine = g_EQUIP_NO         '装置No
    '        Dim lotA As String() = New String() {}
    '        Dim qtyA As String() = New String() {}      '完成数
    '        Dim qty2A As String() = New String() {}     '不良数
    '        Dim Lossqty2A As String() = New String() {}     '過不足数'ADD 苗　2018/1/25

    '        Dim lotCnt = 0
    '        Dim clientProcCd As String = GetBsiteClientString()
    '        For Each drLot As DataRow In dtBake.Rows
    '            If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '                If drLot("COMP_TYPE").ToString.Equals("3") Then
    '                    ReDim Preserve lotA(lotCnt)
    '                    lotA(lotCnt) = drLot("LOT_NO")
    '                    ReDim Preserve qtyA(lotCnt)
    '                    qtyA(lotCnt) = drLot("COMPLETE_NUM")
    '                    ReDim Preserve qty2A(lotCnt)
    '                    qty2A(lotCnt) = drLot("FRAME_NUM") 'UPD 苗　2018/1/18 修正後のフレーム数を設定
    '                    ReDim Preserve Lossqty2A(lotCnt) 'ADD 苗　2018/1/25 
    '                    Lossqty2A(lotCnt) = "" 'ADD 苗　2018/1/25 、1/31
    '                    lotCnt += 1
    '                End If
    '            End If
    '        Next

    '#Region "DEL 2018/4/13 "
    '        ''ADD 苗 2018/4/12 BEGIN
    '        'inParam.Lot = lotA
    '        'inParam.Qty = qtyA
    '        'inParam.Qty2 = qty2A
    '        'inParam.LossQty2 = Lossqty2A
    '        'Dim outParamCheck As InSiteWebService.OutMoveStdBake = MoveStdBakeService_Check(inParam, clientProcCd)
    '        'If outParamCheck.Header IsNot Nothing Then
    '        '    outHeader = outParamCheck.Header
    '        '    Select Case outParamCheck.Header.Status
    '        '        Case STS_SUCCESS
    '        '            '続きます
    '        '        Case Else
    '        '            For Each drLot As DataRow In dtBake.Rows
    '        '                If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '        '                    drLot("RESULT") = "OK"
    '        '                    For Each lotno As String In outParamCheck.Header.ResultLot
    '        '                        If drLot("LOT_NO").ToString.Equals(lotno) Then
    '        '                            drLot("RESULT") = "NG"
    '        '                            Exit For
    '        '                        End If
    '        '                    Next
    '        '                End If
    '        '            Next
    '        '            If outParamCheck.Header.Status = STS_ERROR Then
    '        '                ShowBsiteResult(NG)
    '        '            End If
    '        '            Exit Sub

    '        '    End Select
    '        'End If
    '        'ADD 苗 2018/4/12 END
    '#End Region



    '        Dim outParamCheck As New InSiteWebService.OutMoveStdBake 'ADD 苗 2018/4/13
    '        If bakeStartFinishCheck(3, inParam, outParamCheck, lotCnt, dtBake, lotA, qtyA, qty2A, Lossqty2A) = True Then 'ADD 苗 2018/4/13

    '            'ADD 苗 2018/3/29 BEGIN
    '            Dim intModedNum As Integer = Math.Ceiling(lotCnt / m_bakeNum)

    '            Dim lotB As String() = New String() {}
    '            Dim qtyB As String() = New String() {}
    '            Dim qty2B As String() = New String() {}
    '            Dim Lossqty2B As String() = New String() {}

    '            For i As Integer = 0 To intModedNum - 1
    '                Dim intTempNum As Integer = i * m_bakeNum
    '                If i < intModedNum - 1 Then
    '                    'Erase lotB
    '                    ReDim lotB(m_bakeNum - 1)
    '                    ReDim qtyB(m_bakeNum - 1)
    '                    ReDim qty2B(m_bakeNum - 1)
    '                    ReDim Lossqty2B(m_bakeNum - 1)

    '                Else
    '                    ' Erase lotB
    '                    ReDim lotB(lotCnt - intTempNum - 1)
    '                    ReDim qtyB(lotCnt - intTempNum - 1)
    '                    ReDim qty2B(lotCnt - intTempNum - 1)
    '                    ReDim Lossqty2B(lotCnt - intTempNum - 1)
    '                End If

    '                For intTempIndex As Integer = 0 To m_bakeNum - 1
    '                    If intTempNum + intTempIndex < lotCnt Then
    '                        lotB(intTempIndex) = lotA(intTempNum + intTempIndex)
    '                        qtyB(intTempIndex) = qtyA(intTempNum + intTempIndex)
    '                        qty2B(intTempIndex) = qty2A(intTempNum + intTempIndex)
    '                        Lossqty2B(intTempIndex) = Lossqty2A(intTempNum + intTempIndex)
    '                    End If
    '                Next
    '                'ADD 苗 2018/3/29 END

    '                inParam.Lot = lotB
    '                inParam.Qty = qtyB
    '                inParam.Qty2 = qty2B
    '                inParam.LossQty2 = Lossqty2B 'ADD 苗　2018/1/25 'UPD  苗　2018/3/29
    '                bsiteSuccessFlag = False
    '                If lotCnt <= 0 Then
    '                    bsiteSuccessFlag = True
    '                    '>>20180328 大賀 No122 DBサーバ時刻を使用する
    '                    'serverTime = Now()
    '                    serverTime = m_cData.GetServerTime()
    '                    '<<20180328 大賀 No122 DBサーバ時刻を使用する
    '                    For Each drLot As DataRow In dtBake.Rows
    '                        If drLot("RESULT").Equals("OK") Then
    '                            drLot("RESULT") = String.Empty
    '                        End If
    '                    Next
    '                    'SaveTotalInfo() 'DEL 苗 2018/4/2
    '                    Exit Sub
    '                End If

    '                ShowBsiteWaiting()
    '                Dim outParam As InSiteWebService.OutMoveStdBake = MoveStdBakeService_Execute(inParam, clientProcCd)
    '                lblWait.Visible = False
    '                Me.Enabled = True
    '                '戻り情報を保持
    '                outHeader = outParam.Header

    '                If outParam.Header IsNot Nothing Then
    '                    Select Case outParam.Header.Status
    '                        Case STS_SUCCESS
    '                            bsiteSuccessFlag = True
    '                            '>>20180328 大賀 No122 DBサーバ時刻を使用する
    '                            'If Not DateTime.TryParse(outParam.Header.LotInf.LastActivityDate, serverTime) Then
    '                            '    serverTime = Now()
    '                            'End If
    '                            serverTime = m_cData.GetServerTime()
    '                            '<<20180328 大賀 No122 DBサーバ時刻を使用する

    '                            '次工程の工程コードを取得
    '                            For Each dr As DataRow In dtBake.Rows
    '                                dr("NEXT_PROC_CD") = dr("PROCESS_CD")
    '                            Next
    '                            For j As Integer = 0 To dtBake.Rows.Count - 1
    '                                If dtBake.Rows(j)("COMP_TYPE").ToString.Equals("3") Then
    '                                    'ViewLotService情報取得
    '                                    Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
    '                                    param.Name = dtBake.Rows(j)("LOT_NO").ToString
    '                                    Dim clientStr As String = GetBsiteClientString()
    '                                    Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)

    '                                    If viewLotServiceInfo.LotInf Is Nothing Then
    '                                        'ShowBsiteResult(NG)
    '                                        'CommandFailed()
    '                                    ElseIf viewLotServiceInfo.Header.Status.Equals(STS_ERROR) Then
    '                                        'ShowBsiteResult(NG)
    '                                        'CommandFailed()
    '                                    Else
    '                                        'ShowBsiteResult(OK)
    '                                        Dim dtNextProcCode = m_cData.GetNextProcCode(txtLotNo.Text, viewLotServiceInfo.LotInf.Operation)
    '                                        If dtNextProcCode.Rows.Count > 0 Then
    '                                            dtBake.Rows(j)("NEXT_PROC_CD") = dtNextProcCode.Rows(0)("POSTPROC")
    '                                        Else
    '                                            dtBake.Rows(j)("NEXT_PROC_CD") = viewLotServiceInfo.LotInf.Operation
    '                                        End If

    '                                        'l_lotdata工程更新処理
    '                                        If m_cEquipMat.UpdateL_LotData_Kotei(nextProcCode, txtLotNo.Text) < 0 Then
    '                                            CommandFailed()
    '                                            Exit Sub
    '                                        End If
    '                                    End If
    '                                    dtBake.Rows(j)("RESULT") = ("OK")
    '                                End If
    '                            Next
    '                            ShowBsiteResult(OK)
    '                            'DEL 苗 2018/1/9 Being 成功メッセージを表示しなくように
    '                            'MsgBox(getMsgStr("MSG00114"), MsgBoxStyle.Information)
    '                            'DEL 苗 2018/1/9 End 成功メッセージを表示しなくように

    '                            'SaveTotalInfo()  'DEL 苗 2018/4/2
    '                            For j As Integer = 0 To dtBake.Rows.Count - 1
    '                                If dtBake.Rows(j)("COMP_TYPE").ToString.Equals("2") Then
    '                                    dtBake.Rows(j)("RESULT") = String.Empty
    '                                End If
    '                            Next
    '                        Case Else
    '                            bsiteSuccessFlag = False
    '                            For Each drLot As DataRow In dtBake.Rows
    '                                If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '                                    If drLot("COMP_TYPE").ToString.Equals(TOTAL) Then
    '                                        drLot("RESULT") = "OK"
    '                                    End If
    '                                    For Each lotno As String In outParam.Header.ResultLot
    '                                        If drLot("LOT_NO").ToString.Equals(lotno) Then
    '                                            drLot("RESULT") = "NG"
    '                                            Exit For
    '                                        End If
    '                                    Next
    '                                End If
    '                            Next
    '                            If outParam.Header.Status = STS_ERROR Then
    '                                ShowBsiteResult(NG)
    '                            End If
    '                    End Select
    '                End If
    '            Next
    '            SaveTotalInfo() 'ADD 苗 2018/4/2
    '        End If
    '    End Sub

    '    'ADD 苗 2018/4/13 BEGIN
    '    Private Function bakeStartFinishCheck(type As Integer, ByRef inParam As Object, ByRef outParamCheck As Object, lotCnt As Integer, ByRef dtBake As DataTable, lotA As String(),
    '                                     Optional qtyA As String() = Nothing, Optional qty2A As String() = Nothing, Optional Lossqty2A As String() = Nothing) As Boolean

    '        'Dim inParam As New InSiteWebService.InMoveStdBake


    '        Dim clientProcCd As String = GetBsiteClientString()

    '        'ADD 苗 2018/3/29 BEGIN
    '        Dim intModedNum As Integer = Math.Ceiling(lotCnt / m_bakeNum)

    '        Dim lotB As String() = New String() {}
    '        Dim qtyB As String() = New String() {}
    '        Dim qty2B As String() = New String() {}
    '        Dim Lossqty2B As String() = New String() {}
    '        If type = 3 Then
    '            inParam = New InSiteWebService.InMoveStdBake
    '        Else
    '            inParam = New InSiteWebService.InMoveInBake
    '        End If
    '        If type = 3 Then
    '            inParam.Employee = txtOptNoEnd.Text
    '        Else
    '            inParam.Employee = txtOptNoStt.Text
    '        End If
    '        inParam.Machine = g_EQUIP_NO         '装置No
    '        For i As Integer = 0 To intModedNum - 1
    '            Dim intTempNum As Integer = i * m_bakeNum
    '            If i < intModedNum - 1 Then
    '                'Erase lotB
    '                ReDim lotB(m_bakeNum - 1)
    '                If type = 3 Then
    '                    ReDim qtyB(m_bakeNum - 1)
    '                    ReDim qty2B(m_bakeNum - 1)
    '                    ReDim Lossqty2B(m_bakeNum - 1)
    '                End If
    '            Else
    '                ' Erase lotB
    '                ReDim lotB(lotCnt - intTempNum - 1)
    '                If type = 3 Then
    '                    ReDim qtyB(lotCnt - intTempNum - 1)
    '                    ReDim qty2B(lotCnt - intTempNum - 1)
    '                    ReDim Lossqty2B(lotCnt - intTempNum - 1)
    '                End If
    '            End If

    '            For intTempIndex As Integer = 0 To m_bakeNum - 1
    '                If intTempNum + intTempIndex < lotCnt Then
    '                    lotB(intTempIndex) = lotA(intTempNum + intTempIndex)
    '                    If type = 3 Then
    '                        qtyB(intTempIndex) = qtyA(intTempNum + intTempIndex)
    '                        qty2B(intTempIndex) = qty2A(intTempNum + intTempIndex)
    '                        Lossqty2B(intTempIndex) = Lossqty2A(intTempNum + intTempIndex)
    '                    End If
    '                End If
    '            Next
    '            'ADD 苗 2018/3/29 END

    '            inParam.Lot = lotB
    '            If type = 3 Then
    '                inParam.Qty = qtyB
    '                inParam.Qty2 = qty2B
    '                inParam.LossQty2 = Lossqty2B 'ADD 苗　2018/1/25 'UPD  苗　2018/3/29
    '            End If


    '            If type = 3 Then
    '                outParamCheck = New InSiteWebService.OutMoveStdBake
    '                outParamCheck = MoveStdBakeService_Check(inParam, clientProcCd)

    '            Else
    '                outParamCheck = New InSiteWebService.OutMoveInBake
    '                outParamCheck = MoveInBakeService_Check(inParam, clientProcCd)
    '            End If
    '            If outParamCheck.Header IsNot Nothing Then
    '                outHeader = outParamCheck.Header
    '                Select Case outParamCheck.Header.Status
    '                    Case STS_SUCCESS
    '                        bsiteSuccessFlag = True 'ADD 苗 2018/4/19 
    '                        '続きます
    '                    Case Else
    '                        For Each drLot As DataRow In dtBake.Rows
    '                            If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
    '                                drLot("RESULT") = "OK"
    '                                For Each lotno As String In outParamCheck.Header.ResultLot
    '                                    If drLot("LOT_NO").ToString.Equals(lotno) Then
    '                                        drLot("RESULT") = "NG"
    '                                        Exit For
    '                                    End If
    '                                Next
    '                            End If
    '                        Next
    '                        If outParamCheck.Header.Status = STS_ERROR Then
    '                            ShowBsiteResult(NG)
    '                        End If
    '                        Return False
    '                        bsiteSuccessFlag = False 'ADD 苗 2018/4/19
    '                End Select
    '            End If
    '        Next

    '        Return True
    '    End Function
    '    'ADD 苗 2018/4/13 END

#End Region

#Region "ADD 2018/7/12 "
    ' ベーク完成処理
    Protected Sub bakeWorkFinish(ByRef dtBake As DataTable)
        Dim inParam As New InSiteWebService.InMoveStdBake
        inParam.Employee = txtOptNoEnd.Text
        inParam.Machine = g_EQUIP_NO         '装置No
        Dim lotA As String() = New String() {}
        Dim qtyA As String() = New String() {}      '完成数
        Dim qty2A As String() = New String() {}     '不良数
        Dim Lossqty2A As String() = New String() {}     '過不足数'ADD 苗　2018/1/25

        Dim lotCnt = 0
        Dim clientProcCd As String = GetBsiteClientString()

        'ADD MIAO 2018/11/08 Begin
        Dim chkM As String = ""
        chkM = chkMonitoringAPP()
        If chkM <> "0" Then
            'If MsgBox(getMsgStr("MSG10051"), MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then 'UPD MIAO 2019/1/9
            MsgBox(getMsgStr("MSG10051", chkM)）
            Exit Sub
        End If
        'ADD MIAO 2018/11/08 END

        For Each drLot As DataRow In dtBake.Rows
            If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
                If drLot("COMP_TYPE").ToString.Equals("3") Then
                    ReDim Preserve lotA(lotCnt)
                    lotA(lotCnt) = drLot("LOT_NO")
                    ReDim Preserve qtyA(lotCnt)
                    qtyA(lotCnt) = drLot("COMPLETE_NUM")
                    ReDim Preserve qty2A(lotCnt)
                    qty2A(lotCnt) = drLot("FRAME_NUM") 'UPD 苗　2018/1/18 修正後のフレーム数を設定
                    ReDim Preserve Lossqty2A(lotCnt) 'ADD 苗　2018/1/25 
                    Lossqty2A(lotCnt) = "" 'ADD 苗　2018/1/25 、1/31
                    lotCnt += 1
                End If
            End If
        Next
        inParam.Lot = lotA
        inParam.Qty = qtyA
        inParam.Qty2 = qty2A
        inParam.LossQty2 = Lossqty2A 'ADD 苗　2018/1/25
        bsiteSuccessFlag = False
        If lotCnt <= 0 Then
            bsiteSuccessFlag = True
            '>>20180328 大賀 No122 DBサーバ時刻を使用する
            'serverTime = Now()
            serverTime = m_cData.GetServerTime()
            '<<20180328 大賀 No122 DBサーバ時刻を使用する
            For Each drLot As DataRow In dtBake.Rows
                If drLot("RESULT").Equals("OK") Then
                    drLot("RESULT") = String.Empty
                End If
            Next
            SaveTotalInfo()
            Exit Sub
        End If

        ShowBsiteWaiting()
        Dim outParam As InSiteWebService.OutMoveStdBake = MoveStdBakeService_Execute(inParam, clientProcCd)
        lblWait.Visible = False
        Me.Enabled = True
        '戻り情報を保持
        outHeader = outParam.Header

        If outParam.Header IsNot Nothing Then
            Select Case outParam.Header.Status
                Case STS_SUCCESS
                    bsiteSuccessFlag = True
                    '>>20180328 大賀 No122 DBサーバ時刻を使用する
                    'If Not DateTime.TryParse(outParam.Header.LotInf.LastActivityDate, serverTime) Then
                    '    serverTime = Now()
                    'End If
                    serverTime = m_cData.GetServerTime()
                    '<<20180328 大賀 No122 DBサーバ時刻を使用する

                    '次工程の工程コードを取得
                    For Each dr As DataRow In dtBake.Rows
                        dr("NEXT_PROC_CD") = dr("PROCESS_CD")
                    Next
                    For j As Integer = 0 To dtBake.Rows.Count - 1
                        If dtBake.Rows(j)("COMP_TYPE").ToString.Equals("3") Then
                            'ViewLotService情報取得
                            Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
                            param.Name = dtBake.Rows(j)("LOT_NO").ToString
                            Dim clientStr As String = GetBsiteClientString()
                            Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)

                            If viewLotServiceInfo.LotInf Is Nothing Then
                                'ShowBsiteResult(NG)
                                'CommandFailed()
                            ElseIf viewLotServiceInfo.Header.Status.Equals(STS_ERROR) Then
                                'ShowBsiteResult(NG)
                                'CommandFailed()
                            Else
                                'ShowBsiteResult(OK)
                                Dim dtNextProcCode = m_cData.GetNextProcCode(txtLotNo.Text, viewLotServiceInfo.LotInf.Operation)
                                If dtNextProcCode.Rows.Count > 0 Then
                                    dtBake.Rows(j)("NEXT_PROC_CD") = dtNextProcCode.Rows(0)("POSTPROC")
                                Else
                                    dtBake.Rows(j)("NEXT_PROC_CD") = viewLotServiceInfo.LotInf.Operation
                                End If

                                'l_lotdata工程更新処理
                                If m_cEquipMat.UpdateL_LotData_Kotei(nextProcCode, txtLotNo.Text) < 0 Then
                                    CommandFailed()
                                    Exit Sub
                                End If
                            End If
                            dtBake.Rows(j)("RESULT") = ("OK")
                        End If
                    Next
                    ShowBsiteResult(OK)
                    'DEL 苗 2018/1/9 Being 成功メッセージを表示しなくように
                    'MsgBox(getMsgStr("MSG00114"), MsgBoxStyle.Information)
                    'DEL 苗 2018/1/9 End 成功メッセージを表示しなくように
                    SaveTotalInfo()
                    For j As Integer = 0 To dtBake.Rows.Count - 1
                        If dtBake.Rows(j)("COMP_TYPE").ToString.Equals("2") Then
                            dtBake.Rows(j)("RESULT") = String.Empty
                        End If
                    Next
                Case Else
                    bsiteSuccessFlag = False
                    For Each drLot As DataRow In dtBake.Rows
                        If Not String.IsNullOrEmpty(drLot("LOT_NO")) Then
                            If drLot("COMP_TYPE").ToString.Equals(TOTAL) Then
                                drLot("RESULT") = "OK"
                            End If
                            For Each lotno As String In outParam.Header.ResultLot
                                If drLot("LOT_NO").ToString.Equals(lotno) Then
                                    drLot("RESULT") = "NG"
                                    Exit For
                                End If
                            Next
                        End If
                    Next
                    If outParam.Header.Status = STS_ERROR Then
                        ShowBsiteResult(NG)
                    End If
            End Select
        End If
    End Sub
#End Region
    ' 仕掛移動処理
    Protected Sub moveOperation(ByVal operation As String, ByVal btn As Button, ByVal ignoreW As Boolean)
        Dim inParam As New InSiteWebService.InTransfer
        inParam.Employee = txtOptNoStt.Text
        inParam.Lot = txtLotNo.Text
        inParam.Operation = operation
        inParam.IgnoreSameWfCheck = True
        inParam.IgnoreWarning = ignoreW

        ShowBsiteWaiting()

        outHeader = Nothing
        outLotInfo = Nothing
        Dim clientProcCd = GetBsiteClientString()
        Dim outParam As InSiteWebService.OutTransfer = TransferService_Execute(inParam, clientProcCd)
        '戻り情報を保持
        outHeader = outParam.Header
        outLotInfo = outParam.LotInf

        lblWait.Visible = False
        Me.Enabled = True
        Me.Cursor = Cursors.Arrow
        btn.Enabled = False
        If outParam.Header IsNot Nothing Then
            If outParam.Header.Status.Equals(STS_ERROR) Then
                ShowBsiteResult(NG)
                CommandFailed()
            ElseIf outParam.Header.Status.Equals(STS_WARNING) Then
                If ignoreW Then
                    ShowBsiteResult(NG)
                    CommandFailed()
                Else
                    If ShowBsiteResult(WA) = DefectJudgement.WARNING Then
                        moveOperation(operation, btn, True)
                    Else
                        btn.Enabled = True
                        Exit Sub
                    End If
                End If
            Else
                'ViewLotService情報取得
                Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
                param.Name = txtLotNo.Text
                Dim clientStr As String = GetBsiteClientString()
                Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)

                If viewLotServiceInfo.LotInf Is Nothing Then
                    ShowBsiteResult(NG)
                    CommandFailed()
                ElseIf viewLotServiceInfo.Header.Status.Equals(STS_ERROR) Then
                    ShowBsiteResult(NG)
                    CommandFailed()
                Else
                    ShowBsiteResult(OK)
                    Dim dtNextProcCode = m_cData.GetNextProcCode(txtLotNo.Text, viewLotServiceInfo.LotInf.Operation)
                    If dtNextProcCode.Rows.Count > 0 Then
                        nextProcCode = dtNextProcCode.Rows(0)("POSTPROC")
                    Else
                        nextProcCode = viewLotServiceInfo.LotInf.Operation
                    End If

                    'l_lotdata工程更新処理
                    If m_cEquipMat.UpdateL_LotData_Kotei(nextProcCode, txtLotNo.Text) < 0 Then
                        CommandFailed()
                        Exit Sub
                    End If
                End If
            End If
        End If
    End Sub

    ' 着工キャンセル処理
    Protected Sub cancelWorkStart(ByVal operation As String, ByVal btn As Button)
        Dim inParam As New InSiteWebService.InMoveInCancel
        inParam.Employee = txtOptNoStt.Text
        inParam.Lot = txtLotNo.Text
        inParam.Machine = g_EQUIP_NO         '装置No
        Dim clientProcCd = GetBsiteClientString()

        ShowBsiteWaiting()

        outHeader = Nothing
        outLotInfo = Nothing
        Dim outParam As InSiteWebService.OutMoveInCancel = MoveInCancelService_Execute(inParam, clientProcCd)
        '戻り情報を保持
        outHeader = outParam.Header
        outLotInfo = outParam.LotInf

        lblWait.Visible = False
        Me.Enabled = True

        If outParam.Header IsNot Nothing Then
            If outParam.Header.Status.Equals(STS_ERROR) Then
                '戻り情報を保持
                outHeader = outParam.Header
                'B-siteエラーの場合
                ShowBsiteResult(NG)
                CommandFailed()
            Else
                'l_tag_lotdataステータス更新処理
                If m_cEquipMat.UpdateL_LotData_Status(TagProcessStatus.Ready, txtLotNo.Text) > 0 Then
                    btnStart.Text = getMsgStr("MSG00118")
                    btnStart.BackColor = Drawing.SystemColors.Control
                    IcTag.Status = TagProcessStatus.Ready
                    m_ProcessStatus = ProcessStatus.TagSet
                    ''仕掛移動処理
                    moveOperation(operation, btn, False)
                Else
                    CommandFailed()
                    Exit Sub
                End If
            End If
        End If
    End Sub

    ' 着工をスキップする場合、画面側コードでTrueを返す
    Overridable Function IsJiSkiped() As Boolean
        Return False
    End Function
    Overridable Sub JiSuccess()

        If Not IsJiSkiped() Then
            lblProcessCD.Text = outLotInfo.Operation
            lblProcessCD.Tag = outLotInfo.Operation
            lblNextProcs.Text = outLotInfo.NextOperationDesc
        End If

        If String.IsNullOrEmpty(lblFailedCnt.Text) Then
            lblFailedCnt.Text = "0"
        End If
        If String.IsNullOrEmpty(lblInputCnt.Text) Then
            lblInputCnt.Text = "0"
        End If
        If String.IsNullOrEmpty(lblInputFrm.Text) Then
            lblInputFrm.Text = "0"
        End If
        If String.IsNullOrEmpty(lblInputCross.Text) Then
            lblInputCross.Text = "0"
        End If
        If String.IsNullOrEmpty(lblInputCrossFrm.Text) Then
            lblInputCrossFrm.Text = "0"
        End If

        If IsJiSkiped() Then
            ' bSiteスキップした場合サーバ時刻が設定されていないのでDBサーバの時刻を設定
            serverTime = m_cData.GetServerTime
        End If
        Dim timeNow As DateTime = serverTime

        lblCompleteCnt.Text = lblInputCnt.Text - Me.lblFailedCnt.Text
        '>>20171202 兪
        If fAutoX Then
            'lblCrossCnt.Text = lblInputCross.Text
            lblCrossCnt.Text = "0"
            lblCrossPcbCnt.Text = "0"
        Else
            'UPD 苗 2018/1/11 BEGIN
            lblCrossCnt.Text = IcTag.iCross.ToString 'String.Empty
            lblCrossPcbCnt.Text = inputCrossPcbCnt 'String.Empty
            'UPD 苗 2018/1/11 END
        End If
        '<<20171202 兪

        lblEndTime.Text = String.Empty
        m_dtMat.Rows(0)("BEGIN_TIME") = timeNow.ToString(DATE_TIME_FORMAT_DB)

        'ヘッダの保存
        SaveHeader(timeNow.ToString(DATE_TIME_FORMAT_DB))
        '治工具、材料をDBに保存する
        If SaveEquipMat(timeNow) = False Then
            PutLog(Me.ToString, txtOptNoStt.Text, "データベースへの書込みエラー")
            DbFailedProcess()
            Exit Sub
        Else
            lblBeginTime.Text = timeNow.ToString(DATE_TIME_FORMAT)
            PutLog(Me.ToString, txtOptNoEnd.Text, "データベース保存成功")
        End If

        ''ヘッダの保存
        'If SaveHeader(timeNow.ToString(DATE_TIME_FORMAT_DB)) < 0 Then
        '    DbFailedProcess()
        '    Exit Sub
        'End If

        'ICタグに装置ID、工程をセットする　maruyama@tmc 2017/07/18
        IcTag.szEquipID = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
        IcTag.szProcsCD = nextProcCode

        'ICタグを「着工中」にする
        With IcTag
            Dim sztagData As String = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {12}, {13}",
                                  .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                  .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
            PutLog(Me.ToString, txtOptNoEnd.Text, "ICタグ元データ:       " & sztagData)
        End With
        If IsNothing(IcTag.szUID) Then
            LastTag.Status = TagProcessStatus.Processing
            IcTag = LastTag
            TagWriteBack(LastTag)
        Else
            IcTag.Status = TagProcessStatus.Processing
            '>>20180127 安部
            '>>20180113 安部
            'IcTag.iInput = IcTag.iFinish
            '<<20180127 安部
            TagWriteBack(IcTag)
        End If

        If inputLotType = INPUTLOTTYPE_DIFF Then
            '拡散ロットの場合、拡散ロットNoをキーに設備、工程を更新する
            m_cEquipMat.UpdateL_LotDataFromDiffLotNo(IcTag.szDifLotNo, IcTag.szEquipID, IcTag.szProcsCD)
        End If

        'Bsiteからの返事を待つ
        'TimerWait.Start
        If m_ProcessStatus <> ProcessStatus.Failed Then
            m_ProcessStatus = ProcessStatus.Processing
            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If

        setGridViewLot()

        '>>20170909兪
        m_fIsInSwap = False
        '<<20170909兪
        txtOptNoEnd.Focus() ' 20180301 大賀 着工時に終了作業者にフォーカスを合わす

        If IcTag.Status <> ProcessStatus.Ready Then
            Button1.Enabled = True
        Else
            Button1.Enabled = False
        End If

    End Sub

    Overridable Sub JoSuccess(Optional ByVal fIsFinalTest As Boolean = False)
        Dim fTimer As Boolean = TimerTag.Enabled
        TimerTag.Stop()

        '次工程をtagに保存
        If fIsFinalTest Then
            lblProcessCD.Tag = outLotInfo.Operation
            lblNextProcs.Text = outLotInfo.OperationDesc
        Else
            lblProcessCD.Tag = outLotInfo.Operation
            lblNextProcs.Text = outLotInfo.OperationDesc
        End If

        Dim timeNow As DateTime = DateTime.Now

        'ヘッダ情報を更新する
        UpdateHeader(ProcessStatus.TotalComplete, timeNow.ToString(DATE_TIME_FORMAT_DB))

        '完成情報をDBに保存
        'Dim cnt = m_cEquipMat.SaveTotalInfo(lblEquipID.Text, lblLotNo.Text, timeNow,
        '                             txtOptNoEnd.Text, m_szTable, m_dtHeader,
        '                             m_szCheck,
        '                             m_szSelfCheck,
        '                             m_szTrialCheck,
        '                             m_szSideCheck,
        '                             m_szChgFrame,
        '                             m_szChgBall,
        '                             lblCrossCnt.Text)
        'If cnt < 0 Then
        '    If cnt = -10 Then
        '        PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "更新できる着工記録がありません")
        '        DbFailedProcess("更新できる着工記録がありません。")
        '    Else
        '        PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "データベースへの書込みエラー")
        '        DbFailedProcess()
        '    End If
        '    Exit Sub
        'Else
        '    PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "データベースに保存、結果=" & cnt.ToString)
        '    '完成日時の表示
        '    lblEndTime.Text = timeNow.ToString(DATE_TIME_FORMAT)
        'End If

        If SaveTotalInfo() < 0 Then
            DbFailedProcess()
            Exit Sub
        End If

        '完成日時の表示
        lblEndTime.Text = serverTime.ToString(DATE_TIME_FORMAT)

        'ICタグの装置IDをNULLでセットするmaruyama@tmc 2017/07/18
        IcTag.szEquipID = ""
        'ICタグの工程コードに次工程の工程コードをセットするmaruyama@tmc 2017/07/20
        IcTag.szProcsCD = nextProcCode

        With IcTag
            Dim sztagData As String = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{11},{12},{13}",
                                      .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                      .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
            PutLog(Me.ToString, txtOptNoEnd.Text, "ICタグ元データ:" & sztagData)
        End With
        '>>20180112 佐川
        'IcTag.iInput = CInt(lblInputCnt.Text)
        'IcTag.iFinish = CInt(lblCompleteCnt.Text)
        'IcTag.iFailed = CInt(lblFailedCnt.Text)
        'IcTag.iFrame = CInt(lblPcbCnt.Text)
        'IcTag.iCross = CInt(lblCrossCnt.Text)
        'IcTag.iCrossFrm = CInt(lblCrossPcbCnt.Text)
        'IcTag.fQflag = CBool(btnQflag.Tag)
        'IcTag.fTestflag = m_fTestFlg
        'IcTag.fCheckflag = CBool(btnChecked.Tag)
        '>>20180112 佐川
        IcTag.OnHoldSt = m_IsHolding
        LastTag.iInput = IcTag.iInput
        LastTag.iFinish = IcTag.iFinish
        LastTag.iFailed = IcTag.iFailed
        LastTag.iFrame = IcTag.iFrame
        LastTag.iCross = IcTag.iCross
        LastTag.iCrossFrm = IcTag.iCrossFrm
        LastTag.iDisposalFrmNum = IcTag.iDisposalFrmNum 'ADD 苗 2018/1/24
        m_IsHolding = OnHoldStatus.Normal
        'ICタグを「着工待ち」にする 
        If IsNothing(IcTag.szUID) Then
            LastTag.Status = TagProcessStatus.Ready
            IcTag = LastTag
            TagWriteBack(LastTag)
        Else
            IcTag.Status = TagProcessStatus.Ready
            TagWriteBack(IcTag)
        End If

        If inputLotType = INPUTLOTTYPE_DIFF Then
            '拡散ロットの場合、拡散ロットNoをキーに設備、工程を更新する
            m_cEquipMat.UpdateL_LotDataFromDiffLotNo(IcTag.szDifLotNo, IcTag.szEquipID, IcTag.szProcsCD)
        End If
        Me.Text = strTitle 'DEL 苗 2018/4/23 ADD 苗 2018/5/8
        Threading.Thread.Sleep(20)

        If m_ProcessStatus <> ProcessStatus.Failed Then
            m_ProcessStatus = ProcessStatus.TotalComplete
            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If

        TimerTag.Enabled = fTimer

        m_cFactoryInfo.GetIcTagSwVersion(g_CURRENT_EQUIP_TYPE)
        'frmInital.UpdateMe()

        If m_ProcessStatus <> ProcessStatus.TagSet Then
            ConfScreenItem()
        End If
        'DEL MIAO 20200907 BEGIN
        'If AutoManualMode = 0 And btnTmpChg.Visible = True And btnTmpChg.Text = "切换至 FrameID模式" Then
        '    If MsgBox(getMsgStr("MSG10063"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
        '        btnTmpChg.PerformClick()
        '    End If
        'End If
        'DEL END
        '>>20171010 兪
        '>>2018/02/20 安部 swapTimer削除
        'swapTimer.Start()
        'CheckSwapStatus()
        '<<2018/02/20 安部 swapTimer削除
        '<<20171010 兪


    End Sub

    Protected Sub JcSuccess()
        ' 履歴標準化対応 キャンセル履歴は取り込まない
        ''ヘッダ情報を更新する
        'UpdateHeader(ProcessStatus.Canceled)
        ''履歴を更新
        'Dim cnt = m_cEquipMat.LotCancel(lblEquipID.Text, lblLotNo.Text, m_szTable, m_dtHeader)
        'If cnt < 0 Then
        '    If cnt = -10 Then
        '        PutLog(btnCancel.ToString, txtOptNoStt.Text, "更新できる着工記録がありません")
        '        DbFailedProcess("更新できる着工記録がありません。")
        '    Else
        '        PutLog(btnCancel.ToString, txtOptNoStt.Text, "データベースへの書込みエラー")
        '        DbFailedProcess()
        '    End If
        '    Exit Sub
        'Else
        '    PutLog(btnCancel.ToString, txtOptNoEnd.Text, "データベースに保存、結果=" & cnt.ToString)
        'End If

        ''ヘッダ情報を更新する
        'If UpdateHeader(ProcessStatus.Canceled) < 0 Then
        '    DbFailedProcess()
        '    Exit Sub
        'End If

        'ICタグの装置IDをNULLでセットするmaruyama@tmc 2017/07/18
        IcTag.szEquipID = ""

        'ICタグを「着工待ち」にする 
        With IcTag
            Dim sztagData As String = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{11},{12},{13}",
                                      .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                      .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
            PutLog(Me.ToString, txtOptNoEnd.Text, "ICタグ元データ:" & sztagData)
        End With
        If IsNothing(IcTag.szUID) Then
            LastTag.Status = TagProcessStatus.Ready
            IcTag = LastTag
            TagWriteBack(LastTag)
        Else
            IcTag.Status = TagProcessStatus.Ready
            TagWriteBack(IcTag)
        End If

        If inputLotType = INPUTLOTTYPE_DIFF Then
            '拡散ロットの場合、拡散ロットNoをキーに設備、工程を更新する
            m_cEquipMat.UpdateL_LotDataFromDiffLotNo(IcTag.szDifLotNo, IcTag.szEquipID, IcTag.szProcsCD)
        End If

        If m_ProcessStatus <> ProcessStatus.Failed Then
            m_ProcessStatus = ProcessStatus.Canceled
            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If
        saveHeaderAsType(CANCEL, m_cData.GetServerTime.ToString(DATE_TIME_FORMAT_DB))     '>>20180323 大賀 No117 ロットキャンセルの履歴保存
    End Sub

    Overridable Sub JmSuccess()
        '>>20170717
        If m_fIcTagUsed Then
            TimerTag.Start()
        End If
        '<<20170717
    End Sub

    'データベースに保存エラーの処理
    Protected Sub DbFailedProcess(Optional ByVal szMsg As String = "")
        If String.IsNullOrEmpty(szMsg) Then
            MsgBox(getMsgStr("MSG00028"), MsgBoxStyle.Critical)
        Else
            MsgBox(szMsg)
        End If
        m_szResult = NG
        m_ProcessStatus = ProcessStatus.Failed
        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
    End Sub

    '>>20180323 大賀 No117 ロットキャンセルの履歴保存
    Private Sub saveHeaderAsType(ByVal type As String, ByVal szBeginTime As String, Optional ByVal tagData As TagData = Nothing)
        SaveHeader(szBeginTime, tagData)    ' 既存処理を利用
        m_dtHeader.Rows(0)("TYPE") = type   ' TYPEを上書き
        '>>20180328 大賀 No122 DBサーバ時刻を使用する
        If String.IsNullOrEmpty(m_dtMat.Rows(0)("BEGIN_TIME").ToString) Then
            m_dtHeader.Rows(0)("BEGIN_TIME") = m_cData.GetServerTime()
        Else
            m_dtHeader.Rows(0)("BEGIN_TIME") = m_dtMat.Rows(0)("BEGIN_TIME")
        End If
        '<<20180328 大賀 No122 DBサーバ時刻を使用する
        m_cEquipMat.SaveHeader(m_dtHeader, 0, lotNo, IcTag.szEquipID, type, serverTime) ' DBに保存
    End Sub
    '<<20180323 大賀 No117 ロットキャンセルの履歴保存

    Protected Sub SaveHeader(ByVal szBeginTime As String, Optional ByVal tagData As TagData = Nothing)
        With m_dtHeader.Rows(0)
            .Item("LOT_NO") = lotNo
            .Item("KOUTEI_CD") = lblProcessCD.Text
            .Item("TYPE") = BEGIN
            .Item("OPERATOR") = txtOptNoStt.Text
            .Item("EQUIP_ID") = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
            .Item("PROD_NAME") = lblkindNm.Text
            .Item("DIFF_LOT") = lblDiffLotNo.Text
            .Item("PB_LAYOUT") = lblPbLayout.Text
            .Item("SHAPE") = lblShape.Text
            .Item("BEGIN_TIME") = szBeginTime
            .Item("BEGIN_OPT") = txtOptNoStt.Text
            .Item("INPUT_QTY") = IcTag.iInput.ToString
            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
            If wf_write_flag = WRITE_WAFER Then
                .Item("INPUT_WAFER_QTY") = lblInputFrm.Text
            Else
                .Item("INPUTFRM_QTY") = IcTag.iFrame.ToString
            End If
            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
            .Item("INPUTCROSS_QTY") = IcTag.iCross

            .Item("CROSS_QTY") = lblCrossCnt.Text 'ADD 苗 2018/1/17
            .Item("CROSS_FRMQTY") = lblCrossPcbCnt.Text 'ADD 苗 2018/1/17

            '>>20180111 兪
            If IsNothing(tagData.szLotNo) Then 'UPD 苗 2018/1/24 tagDataの値が無くても、Nothingではない
                .Item("COMPLETE_QTY") = lblCompleteCnt.Text
                .Item("DEFECT_QTY") = lblFailedCnt.Text
                '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                If wf_write_flag = WRITE_WAFER Then
                    .Item("WAFER_QTY") = lblPcbCnt.Text
                Else
                    .Item("FRAME_QTY") = lblPcbCnt.Text
                End If
                '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                '.Item("CROSS_QTY") = lblCrossCnt.Text'DEL 苗 2018/1/17
                '.Item("CROSS_FRMQTY") = lblCrossPcbCnt.Text'DEL 苗 2018/1/17
                .Item("IS_CHECKED") = btnChecked.Tag
                .Item("Q_FLAG") = btnQflag.Tag
            Else
                .Item("COMPLETE_QTY") = tagData.iFinish
                .Item("DEFECT_QTY") = tagData.iFailed
                .Item("FRAME_QTY") = tagData.iFrame
                '.Item("CROSS_QTY") = tagData.iCross'DEL 苗 2018/1/17
                '.Item("CROSS_FRMQTY") = tagData.iCrossFrm'DEL 苗 2018/1/17
                .Item("IS_CHECKED") = tagData.fCheckflag
                .Item("Q_FLAG") = tagData.fQflag
            End If
            '<<20180111 兪
            .Item("INPUTCROSS_FRMQTY") = inputCrossPcbCnt
        End With

        'Return m_cEquipMat.SaveHeader(m_dtHeader, ProcessStatus.Processing)
    End Sub

    Protected Sub SaveBakeHeader(ByVal szBeginTime As String, ByVal dtLot As DataRow)
        With m_dtHeader.Rows(0)
            Dim type As String = dtLot("LOT_STATE").ToString

            .Item("LOT_NO") = dtLot("LOT_NO").ToString
            .Item("KOUTEI_CD") = lblProcessCD.Text
            .Item("TYPE") = type
            If type.Equals("0") Then
                .Item("OPERATOR") = txtOptNoStt.Text
                .Item("BEGIN_TIME") = szBeginTime
                .Item("INPUT_QTY") = dtLot("COMPLETE_NUM").ToString
                .Item("COMPLETE_QTY") = "0"
                .Item("DEFECT_QTY") = "0"
                .Item("FRAME_QTY") = "0"
            Else
                .Item("OPERATOR") = txtOptNoEnd.Text
                .Item("BEGIN_TIME") = szBeginTime
                .Item("INPUT_QTY") = dtLot("INV_NUM").ToString
                .Item("COMPLETE_QTY") = dtLot("COMPLETE_NUM").ToString
                .Item("DEFECT_QTY") = dtLot("FAILD_NUM").ToString
                .Item("FRAME_QTY") = dtLot("FRAME_NUM").ToString
            End If
            .Item("EQUIP_ID") = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
            .Item("PROD_NAME") = dtLot("PROD_NAME").ToString
            .Item("DIFF_LOT") = dtLot("WAFERLOT_NO").ToString
            .Item("PB_LAYOUT") = dtLot("PB_LAYOUT")
            .Item("SHAPE") = dtLot("SHAPE").ToString
            .Item("BEGIN_OPT") = txtOptNoStt.Text
            .Item("INPUTFRM_QTY") = dtLot("PRE_FRAME_NUM").ToString
            .Item("INPUTCROSS_QTY") = dtLot("PRE_BAD_MARK_NUM").ToString
            .Item("CROSS_FRMQTY") = dtLot("BAD_MARK_FRMNUM").ToString
            .Item("INPUTCROSS_FRMQTY") = dtLot("PRE_BAD_MARK_FRMNUM").ToString
            .Item("COMPLETE_OPT") = txtOptNoEnd.Text
            .Item("CROSS_QTY") = dtLot("BAD_MARK_NUM").ToString
            .Item("IS_CHECKED") = False
            .Item("Q_FLAG") = CBool(dtLot("Q_FLAG").ToString)
        End With

    End Sub

    Protected Sub SavePlateHeader(ByVal szBeginTime As String, ByVal dtLot As DataRow)
        With m_dtHeader.Rows(0)
            Dim type As String = dtLot("LOT_STATE").ToString

            .Item("LOT_NO") = dtLot("LOT_NO").ToString
            .Item("KOUTEI_CD") = lblProcessCD.Text
            .Item("TYPE") = CInt(DirectCast([Enum].Parse(GetType(ProcessStatus), type), ProcessStatus)).ToString
            If type.Equals(ProcessStatus.Ready.ToString) Then
                .Item("OPERATOR") = dtLot("START_OPT")
                .Item("BEGIN_TIME") = szBeginTime
            Else
                .Item("OPERATOR") = dtLot("FINISH_OPT")
                .Item("BEGIN_TIME") = dtLot("START_DATE")
            End If
            .Item("EQUIP_ID") = dtLot("EQP_NO")
            .Item("PROD_NAME") = dtLot("PROD_NAME").ToString
            .Item("DIFF_LOT") = dtLot("WAFERLOT_NO").ToString
            .Item("PB_LAYOUT") = dtLot("PB_LAYOUT")
            .Item("SHAPE") = dtLot("SHAPE").ToString
            .Item("BEGIN_OPT") = dtLot("START_OPT")
            .Item("INPUT_QTY") = dtLot("INV_NUM").ToString
            .Item("INPUTFRM_QTY") = dtLot("PRE_FRAME_QTY").ToString
            .Item("INPUTCROSS_QTY") = dtLot("PRE_BAD_MARK_NUM").ToString
            .Item("COMPLETE_OPT") = dtLot("FINISH_OPT")
            .Item("COMPLETE_QTY") = dtLot("COMPLETE_NUM").ToString
            .Item("DEFECT_QTY") = dtLot("FAILED_NUM").ToString
            .Item("FRAME_QTY") = dtLot("FRAME_NUM").ToString
            .Item("CROSS_QTY") = dtLot("BAD_MARK_NUM").ToString
            .Item("INPUTCROSS_FRMQTY") = dtLot("PRE_CROSS_PCB_CNT").ToString
            .Item("CROSS_FRMQTY") = dtLot("CROSS_PCB_CNT").ToString
            .Item("IS_CHECKED") = False
            .Item("Q_FLAG") = CBool(dtLot("Q_FLAG").ToString)
        End With

    End Sub

    Protected Sub UpdateHeader(ByVal status As ProcessStatus, Optional ByVal szEndTime As String = "", Optional ByVal tagData As TagData = Nothing)
        'With m_dtHeader.Rows(0)
        '    .Item("EQUIP_ID") = lblEquipID.Text
        '    .Item("KOUTEI_CD") = lblProcessCD.Text
        '    If String.IsNullOrEmpty(m_dtMat.Rows(0)("BEGIN_TIME").ToString) Then
        '        .Item("BEGIN_TIME") = DateTime.Now()
        '    Else
        '        .Item("BEGIN_TIME") = m_dtMat.Rows(0)("BEGIN_TIME")
        '    End If
        '    Select Case status
        '        Case ProcessStatus.ManufComplete
        '            .Item("STATUS") = "製造完成"
        '            .Item("COMPLETE_TIME") = szEndTime
        '            .Item("COMPLETE_OPT") = txtOptNoEnd.Text
        '        Case ProcessStatus.TotalComplete
        '            .Item("STATUS") = "計上完成"
        '            .Item("TOTAL_TIME") = szEndTime
        '            .Item("TOTAL_OPT") = txtOptNoEnd.Text
        '        Case ProcessStatus.Canceled
        '            .Item("STATUS") = "キャンセル"
        '        Case ProcessStatus.Hold
        '            .Item("STATUS") = "保留"
        '    End Select
        '    .Item("PROD_NAME") = lblkindNm.Text
        '    .Item("LOT_NO") = lblLotNo.Text
        '    .Item("DIFF_LOT") = lblDiffLotNo.Text
        '    .Item("PB_LAYOUT") = lblPbLayout.Text
        '    .Item("SHAPE") = lblShape.Text
        '    .Item("INPUT_QTY") = lblInputCnt.Text
        '    .Item("INPUTFRM_QTY") = lblInputFrm.Text
        '    .Item("INPUTCROSS_QTY") = lblInputCross.Text
        '    .Item("COMPLETE_QTY") = lblCompleteCnt.Text
        '    .Item("DEFECT_QTY") = lblFailedCnt.Text
        '    .Item("FRAME_QTY") = lblPcbCnt.Text
        '    .Item("CROSS_QTY") = lblCrossCnt.Text
        '    .Item("IS_CHECKED") = btnChecked.Tag
        '    .Item("Q_FLAG") = btnQflag.Tag
        'End With
        '>>20180111 兪
        With m_dtHeader.Rows(0)
            .Item("LOT_NO") = lotNo
            .Item("KOUTEI_CD") = lblProcessCD.Text
            .Item("OPERATOR") = txtOptNoEnd.Text
            .Item("EQUIP_ID") = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
            If String.IsNullOrEmpty(m_dtMat.Rows(0)("BEGIN_TIME").ToString) Then
                '>>20180328 大賀 No122 DBサーバ時刻を使用する
                '.Item("BEGIN_TIME")  = DateTime.Now()
                .Item("BEGIN_TIME") = m_cData.GetServerTime()
                '<<20180328 大賀 No122 DBサーバ時刻を使用する
            Else
                .Item("BEGIN_TIME") = m_dtMat.Rows(0)("BEGIN_TIME")
            End If
            .Item("BEGIN_OPT") = txtOptNoStt.Text
            Select Case status
                Case ProcessStatus.ManufComplete
                    '.Item("COMPLETE_TIME") = szEndTime
                    .Item("COMPLETE_OPT") = txtOptNoEnd.Text
                Case ProcessStatus.TotalComplete
                    '.Item("COMPLETE_TIME") = szEndTime
                    .Item("COMPLETE_OPT") = txtOptNoEnd.Text
                    'Case ProcessStatus.Canceled
                    '    .Item("STATUS") = "キャンセル"
                    'Case ProcessStatus.Hold
                    '    .Item("STATUS") = "保留"
            End Select
            .Item("PROD_NAME") = lblkindNm.Text
            .Item("DIFF_LOT") = lblDiffLotNo.Text
            .Item("PB_LAYOUT") = lblPbLayout.Text
            .Item("SHAPE") = lblShape.Text
            .Item("INPUT_QTY") = lblInputCnt.Text
            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
            If wf_write_flag = WRITE_WAFER Then
                .Item("INPUT_WAFER_QTY") = lblInputFrm.Text
            Else
                .Item("INPUTFRM_QTY") = IcTag.iFrame.ToString
            End If
            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
            .Item("INPUTCROSS_QTY") = lblInputCross.Text
            .Item("INPUTCROSS_FRMQTY") = lblInputCrossFrm.Text
            If IsNothing(tagData.szLotNo) Then 'UPD 苗 2018/1/24 tagDataの値が無くても、Nothingではない
                .Item("COMPLETE_QTY") = lblCompleteCnt.Text
                .Item("DEFECT_QTY") = lblFailedCnt.Text
                '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                If wf_write_flag = WRITE_WAFER Then
                    .Item("WAFER_QTY") = lblPcbCnt.Text
                Else
                    .Item("FRAME_QTY") = lblPcbCnt.Text
                End If
                '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                .Item("CROSS_QTY") = lblCrossCnt.Text
                .Item("CROSS_FRMQTY") = lblCrossPcbCnt.Text
                .Item("IS_CHECKED") = btnChecked.Tag
                .Item("Q_FLAG") = btnQflag.Tag
            Else
                .Item("COMPLETE_QTY") = tagData.iFinish
                .Item("DEFECT_QTY") = tagData.iFailed
                '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                If wf_write_flag = WRITE_WAFER Then
                    .Item("WAFER_QTY") = tagData.waferNum
                Else
                    .Item("FRAME_QTY") = tagData.iFrame
                End If
                '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                .Item("CROSS_QTY") = tagData.iCross
                .Item("CROSS_FRMQTY") = tagData.iCrossFrm
                .Item("IS_CHECKED") = tagData.fCheckflag
                .Item("Q_FLAG") = tagData.fQflag
            End If
            '<<20180111 兪
        End With

        'Return m_cEquipMat.UpdateHeader(m_dtHeader, status)
    End Sub

    '治工具のクリア
    Overridable Sub ClearCollCells()
        InitualizeCollData()

        Dim i As Integer
        For i = 0 To PASS_SCORE

            'バーコード項目をクリア
            Dim ctr() As Control = Me.Controls.Find(String.Format("lbl{0}03", FixCharZero((i + 1).ToString, 2)), True)
            If ctr.Length > 0 AndAlso ctr(0).GetType = GetType(BarCodeCell) Then
                Dim bcc As BarCodeCell = CType(ctr(0), BarCodeCell)
                bcc.Clear()
            End If

            Dim txtData() As Control = Me.Controls.Find(String.Format("txtData{0}", i), False)
            If txtData.Length > 0 Then
                Dim btnBarCode() As Control = txtData(0).Parent.Controls.Find("btnBarCode" & (CInt(txtData(0).Tag) - 1).ToString, False)
                If btnBarCode.Length > 0 AndAlso btnBarCode(0).Enabled Then
                    txtData(0).BackColor = BARCODE_INIT_COLOR
                    Dim lblData() As Control = Me.Controls.Find(String.Format("lbl{0}03", txtData(0).Tag), False)
                    If lblData.Length > 0 And i > 0 Then
                        lblData(0).BackColor = BARCODE_INIT_COLOR
                    End If
                Else
                    txtData(0).BackColor = NORMAL_INIT_COLOR
                    Dim lblData() As Control = Me.Controls.Find(String.Format("lbl{0}03", txtData(0).Tag), False)
                    If lblData.Length > 0 And i > 0 Then
                        lblData(0).BackColor = NORMAL_INIT_COLOR
                    End If
                End If
            End If
        Next
    End Sub

    '工程コードチェック
    Overridable Function CheckProcsCD() As Boolean
        If String.IsNullOrEmpty(IcTag.szProcsCD) Then
            Return False
        End If
        Select Case IcTag.szProcsCD
            Case "M999"
                txtOptNoStt.Clear()
                Return True
            Case "N999"
                txtOptNoStt.Clear()
                Return True
            Case Else
                '蘇州対応　maruyama@tmc
                For i As Integer = 0 To m_cIdohyo.ProcCdInfo.Length() - 1
                    If IcTag.szProcsCD.Equals(m_cIdohyo.ProcCdInfo(i)) Then
                        m_szProc = IcTag.szProcsCD
                        Return True
                    End If
                Next
                Return False
        End Select
    End Function

    '着工装置チェック
    Overridable Function CheckEquipID() As Boolean
        If IcTag.Status = TagProcessStatus.Ready AndAlso
           IcTag.OnHoldSt = OnHoldStatus.Normal Then
            Return True
        Else
            '着工中、保留中のロットは必ず着工時の装置で処理すること
            If g_EQUIP_NO.Equals(IcTag.szEquipID) Then 'UPD 苗 2018/1/19 装置No.の対応
                Return True
            Else
                Return False
            End If
        End If
    End Function

    Overridable Sub InitualizeCollData()
        m_fColl = False
    End Sub

    '保留処理
    Protected Sub HoldProcess()
        PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "ロット保留")
        '保留情報の保存
        Dim cnt = SaveCompleteInfo(ProcessStatus.Hold)
        If cnt < 0 Then
            If cnt = -10 Then
                PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "更新できる着工記録がありません。")
                DbFailedProcess("更新できる着工記録がありません。")
            Else
                PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "データベースエラー")
                DbFailedProcess()
            End If
            Me.Enabled = True
            Exit Sub
        Else
            PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "データベースに保存、結果=" & cnt.ToString)
        End If

        'ICタグ書込み

        With IcTag
            Dim sztagData As String = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{11},{12},{13}",
                                      .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD,
                                      .iInput, .iFinish, .iFailed, .iFrame, .iCross, .iCrossFrm, .fQflag, .fCheckflag, .fTestflag)
            PutLog(Me.ToString, txtOptNoEnd.Text, "ICタグ元データ:" & sztagData)
        End With
        m_IsHolding = OnHoldStatus.OnHold
        IcTag.OnHoldSt = OnHoldStatus.OnHold
        TagWriteBack(IcTag)
    End Sub

#End Region

#Region "ICタグ状態"
    Private fIsTagSet As Boolean

    '>>20171010 兪
    Private Const CHECK_INTERVAL As Integer = 500
    Private Const NORMAL_INTERVAL As Integer = 500
    '<<20171010 兪
    Private Const CHK_HOLD_INTERVAL As Integer = 15
    '>>20170714
    Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerTag.Tick
        Static Dim fWaited As Boolean = False
        Static Dim iHoldTimer As Integer = CHK_HOLD_INTERVAL

        'データ受信待ち
        If lblWait.Visible Then
            Exit Sub
        End If
        If m_fRecieving Then
            Exit Sub
        End If
        If m_fIsGettingData Then
            Exit Sub
        End If
        If m_fIsWriting Then
            Exit Sub
        End If

        ''保留解除チェック
        'If iHoldTimer > CHK_HOLD_INTERVAL Then
        '    iHoldTimer = 0
        '    Me.Enabled = True
        '    m_ProcessStatus = ProcessStatus.TagSet
        '    RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        '    Exit Sub
        'End If

        'If m_IsHolding = OnHoldStatus.OnHold AndAlso m_TagStatus = TagStatus.All Then

        '    If iHoldTimer >= CHK_HOLD_INTERVAL Then

        '        If Not IsBsiteOnHold() Then
        '            TimerTag.Stop()

        '            m_IsHolding = OnHoldStatus.Solved
        '            IcTag.OnHoldSt = OnHoldStatus.Solved
        '            IcTag.iInput = IcTag.iFinish - CInt(lblFailedCnt.Text)
        '            IcTag.iFinish = IcTag.iInput
        '            IcTag.iCross = IcTag.iCross + CInt(lblFailedCnt.Text)
        '            IcTag.iFailed = 0
        '            IcTag.Status = TagProcessStatus.Ready
        '            TagWriteBack(IcTag)

        '            iHoldTimer = CHK_HOLD_INTERVAL + 1
        '            TimerTag.Start()
        '            Exit Sub
        '        End If

        '    Else
        '        iHoldTimer += 1
        '    End If

        'End If

        '初期状態待ち
        If String.IsNullOrEmpty(IcTag.szLotNo) Then
            g_cRFID.CheckTag()
            m_TagStatus = TagStatus.Non
            TimerTag.Interval = CHECK_INTERVAL
            Exit Sub
        End If

        Try
            Select Case m_TagStatus
                Case TagStatus.Non
                    If m_fTagDataRecived Then
                        m_TagStatus = TagStatus.TagSet
                    Else
                        m_TagStatus = TagStatus.Non
                    End If
                    TimerTag.Interval = NORMAL_INTERVAL
                Case TagStatus.TagSet
                    m_TagStatus = TagStatus.All
                    'g_cRFID.SetMod(clsRfidTag.Mode.RDLOOP, MULTI_TAG, NO_BEEP)
                    If Not IcTag.szLotNo.Trim.Equals(lblLotNo.Text) OrElse
                                    m_ProcessStatus = ProcessStatus.Ready Then
                        m_ProcessStatus = ProcessStatus.TagSet
                        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    ElseIf m_ProcessStatus = ProcessStatus.Ready Then
                        m_ProcessStatus = ProcessStatus.TagSet
                        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    ElseIf m_ProcessStatus = ProcessStatus.Processing AndAlso Not fIsTagSet Then
                        m_ProcessStatus = ProcessStatus.TagSet
                        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
                    End If
                Case TagStatus.All
                    m_TagStatus = TagStatus.Check1
                    'ICタグチェック
                    g_fNoTagResp = False
                    m_fTagDataRecived = False
                    g_cRFID.CheckTag()
                    TimerTag.Interval = CHECK_INTERVAL
                Case TagStatus.Check1
                    If m_fTagDataRecived Then
                        m_TagStatus = TagStatus.All
                        'g_cRFID.SetMod(clsRfidTag.Mode.RDLOOP, MULTI_TAG, NO_BEEP)
                        TimerTag.Interval = NORMAL_INTERVAL
                    ElseIf g_fNoTagResp Then
                        'ICタグチェック失敗
                        m_TagStatus = TagStatus.Remove
                        TimerTag.Interval = NORMAL_INTERVAL
                    Else
                        m_TagStatus = TagStatus.Check2
                    End If
                Case TagStatus.Check2
                    If m_fTagDataRecived Then
                        m_TagStatus = TagStatus.All
                        'g_cRFID.SetMod(clsRfidTag.Mode.RDLOOP, MULTI_TAG, NO_BEEP)
                    Else
                        'ICタグチェック失敗
                        m_TagStatus = TagStatus.Remove
                    End If
                    TimerTag.Interval = NORMAL_INTERVAL
                Case TagStatus.Remove
                    LastTag = New TagData

                    m_TagStatus = TagStatus.Non

                    'g_cRFID.SetMod(clsRfidTag.Mode.RDLOOP, MULTI_TAG, BEEP)
                    btnManufComp.Enabled = False
                    btnTotalComp.Enabled = False
                    btnCancel.Enabled = False

                    iHoldTimer = CHK_HOLD_INTERVAL

                    fIsTagSet = False
                    PutLog(Me.ToString, String.Empty, "ICタグが抜かれた")
                    'If m_ProcessStatus = ProcessStatus.Processing OrElse _
                    '                            m_ProcessStatus = ProcessStatus.ManufComplete Then
                    '    '数量の保存
                    '    If SaveQty() < 0 Then
                    '        PutLog(Me.ToString, String.Empty, "数量自動保存失敗")
                    '        DbFailedProcess("数量自動保存失敗しました。")
                    '    Else
                    '        PutLog(Me.ToString, String.Empty, "数量を自動保存した")
                    '    End If
                    'End If
                    If m_ProcessStatus = ProcessStatus.TagSet OrElse
                        m_ProcessStatus = ProcessStatus.ManufComplete OrElse
                        m_ProcessStatus = ProcessStatus.TotalComplete OrElse
                        m_ProcessStatus = ProcessStatus.Failed OrElse
                        m_ProcessStatus = ProcessStatus.Preprocess OrElse
                        m_ProcessStatus = ProcessStatus.Canceled Then
                        g_cRFID.ClearData()
                        ''ヘッダーをクリアする
                        'ClearHeader()
                        '画面状態復元
                        ResumeTitle()
                    End If

                    If m_ProcessStatus = ProcessStatus.Hold Then
                        Me.Enabled = True
                        '画面状態復元
                        ResumeTitle()
                    End If

                    '装置工程CD再取得
                    m_cIdohyo.GetEquipInfoByID(g_CURRENT_EQUIP_ID)
                    g_EQUIP_NO = m_cIdohyo.EquipInfo.szEquipNo
                    lblProcessCD.Text = m_cIdohyo.EquipInfo.szKouteiCD

                    TimerTag.Interval = NORMAL_INTERVAL
            End Select

        Catch ex As Exception
            TimerTag.Stop()
            PutLog(sender.ToString, "", ex.Message)
            MsgBox(ex.Message, MsgBoxStyle.Critical, "ICタグエラー")
            Me.Close()
        End Try

    End Sub
    '<<20170714

    '画面状態復元
    Overridable Sub ResumeTitle()
        m_ProcessStatus = ProcessStatus.Ready
        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
    End Sub
#End Region

#Region "シリアルデータ取得"
    Private Const CHECK_COUNT = 20
    '******************************************************************************
    '*  シリアルポートからデータを受取処理
    '******************************************************************************
    '>>20170714
    Protected Sub DataReceive(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
        Dim serialPort As IO.Ports.SerialPort = CType(sender, IO.Ports.SerialPort)
        Static Dim lstByte As New List(Of Byte)
        Static Dim m_fDataEnded As Boolean
        Static Dim SerialDataProcs As New Delegate_TagDataProcess(AddressOf TagDataProcess)
        Static Dim iCheckCount As Integer = CHECK_COUNT

        g_SerialArg = e

        Try
            While (serialPort.BytesToRead > 0)
                m_fRecieving = True
                While (serialPort.BytesToRead > 0)

                    Dim byteTmp As Byte = serialPort.ReadByte
                    If byteTmp = clsRfidTag.CR Then 'And lstByte.Item(lstByte.Count - 2) = clsRfidTag.ETX Then
                        lstByte.Add(byteTmp)
                        m_fDataEnded = True
                        Exit While
                    End If
                    lstByte.Add(byteTmp)
                End While

                If m_fDataEnded Then

                    '読取ったデータの整理
                    If lstByte.Count >= clsRfidTag.MIN_BYTE + DATA_LENGTH Then
                        m_fTagDataRecived = True
                        g_fDataOK = True

                        Dim txtLot As TextBox
                        If btnLotTxt.Enabled Then
                            txtLot = txtLotNo
                        Else
                            txtLot = txtDiffLot
                        End If
                        Invoke(SerialDataProcs, txtLot, lstByte.ToArray)
                    ElseIf lstByte.Count > 0 Then

                        If OK.Equals(BytesToString(lstByte.ToArray)) Then
                            g_fRespOK = True
                            If lstByte(4) = &HA1 Then
                                m_fTagWriteFailed = False
                            End If
                        Else
                            g_fRespOK = False
                            g_fNACK = True

                            If BytesToString(lstByte.ToArray).StartsWith("ERR") Then
                                m_fTagWriteFailed = True
                            End If
                        End If
                    End If
                    lstByte.Clear()
                    m_fDataEnded = False
                End If

            End While
        Catch ex As Exception
            'If Not (m_fTagSet) Then
            PutLog(sender.ToString, "", ex.Message)
            TimerTag.Stop()
            MsgBox(ex.Message)
            'Me.Close()
            'End If
        End Try

        m_fRecieving = False
    End Sub
    '<<20170714

    Public Sub RecieveData()

    End Sub

    Private m_fRecieving As Boolean = False
#End Region

#Region "ICタグデータ処理"
    Protected Delegate Sub Delegate_TagDataProcess(ByVal sender As System.Object, ByVal data() As Byte)
    '>>20170714
    'Dim dummyData() As Byte = {&H2, &H0, &H4C, &H78, &H80, &HFE, &HD, &H45,
    '                           &H50, &H1, &H4, &HE0, &H42, &H48, &H30, &H30,
    '                           &H34, &H35, &H38, &H52, &H20, &H20, &H20, &H20,
    '                           &H20, &H20, &H20, &H20, &H20, &H20, &H20, &H20,
    '                            &H43, &H50, &H48, &H36, &H32, &H32, &H2D, &H31,
    '                            &H33, &H20, &H20, &H20, &H20, &H20, &H20, &H20,
    '                            &H20, &H20, &H20, &H20, &H0, &H44, &H42, &H42,
    '                            &H45, &H30, &H30, &H30, &H30, &H30, &H34, &H20,
    '                            &H20, &H20, &H20, &H20, &H20, &H4D, &H32, &H30,
    '                            &H30, &H20, &H20, &H20, &H20, &H20, &H20, &H4,
    '                            &HDB, &H4, &HDB, &H0, &H0, &H0, &H70, &H0, &H7,
    '                            &H0, &H0, &H0, &H0, &H0, &H1, &H80, &H0, &H0,
    '                            &H0, &H0, &H0, &H0, &H0, &H0, &H0, &H0, &H0,
    '                            &H0, &H0, &H40, &H3, &H40, &H0, &H0, &H0, &H0,
    '                            &H0, &H0, &H0, &H0, &H0, &H0, &H0, &H0, &H3,
    '                            &H5A, &HD}
    '<<20170714

    'タグから取得したデータを処理する

    '>>20170714
    Protected Sub TagDataProcess(ByVal sender As System.Object, ByVal byteData() As Byte)
        m_fIsGettingData = True

        '>>20180111 兪
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim tagData As New List(Of TagData)

        '>>20171225 兪
        If byteData.Length > 1 AndAlso CByte(clsRfidTag.CR) = byteData(byteData.Length - 1) Then
            Dim szLot As String = BytesToString(byteData.ToArray).Replace(Chr(clsRfidTag.CR).ToString, "")
            '>>20180110 兪
            '固定式バーコードリーダーから同じロットを読込んだら処理しない
            If szLot.Equals(txtData.Text) AndAlso Not String.IsNullOrEmpty(IcTag.szLotNo) Then
                IcTag = LastTag
                m_fIsGettingData = False
                Exit Sub
            End If
            txtData.Text = BytesToString(byteData.ToArray).Replace(Chr(clsRfidTag.CR).ToString, "")
            If Not txtData.Text.Equals(IcTag.szLotNo) AndAlso Not txtData.Text.Equals(IcTag.szDifLotNo) Then
                '入力ロットタイプ毎に処理を呼出し
                If inputLotType = INPUTLOTTYPE_DIFF Then
                    txtDiffLot_KeyPress(txtDiffLot, New KeyPressEventArgs(vbCr))
                Else
                    txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                End If
                Exit Sub
            End If
            '<<20180110 兪
        End If
        '<<20171225 兪
        txtData.Text = txtData.Text.ToUpper
        Dim lotArr() As String

        '拡散ロットNo.の場合、組立ロットNo.にてデータ取得
        If txtData.Name.Equals("txtDiffLot") Then

            '>>20180111 佐川
            'txtData = txtLotNo
            '<<20180111 佐川
            lotArr = m_cData.GetGroupLot(txtData.Text)
            If String.IsNullOrEmpty(txtLotNo.Text) Then
                txtLotNo.Text = m_cData.GetDiffLotData(lotArr(0))
            End If
        Else
            lotArr = {txtData.Text}
        End If

        For Each lot In lotArr
            '>>2018/2/27 大賀 IcTagデータ設定共通化
            Dim tag = frmStartCompleteBase.TagData.Initalize
            '<<2018/2/27 大賀 IcTagデータ設定共通化

            'l_lotdataよりデータを取得
            dtData = m_cData.GetWbLotData(lot)
            If dtData.Rows.Count > 0 Then
                '>>2018/2/27 大賀 IcTagデータ設定共通化
                tag.setData(dtData)
                '×印枚数を変数に代入
                inputCrossPcbCnt = tag.iCrossFrm
                '<<2018/2/27 大賀 IcTagデータ設定共通化
            End If
            tagData.Add(tag)
        Next

        dtError.Clear()
        dgvError.DataSource = dtError

        IcTag = tagData.ToArray()(0)
        GroupID = tagData.ToArray
        g_fDataSet = True

        '組立ロットNo.（共通）が空白であれば処理中止
        If String.IsNullOrEmpty(IcTag.szLotNo) And txtData.Name.Equals("txtLotNo") Then
            'Timer1.Stop()
            ' l_tag_lot_dataにデータが存在しない場合エラー
            MsgBox(getMsgStr("MSG10011", txtData.Text))
            m_MoveInCheck = False
            m_fIsGettingData = False
            enableBtn()
            Exit Sub
        End If
        g_LOT_NO = IcTag.szLotNo

        'コメントアウト　maruyama@tmc
        'If Not String.IsNullOrEmpty(IcTag.szUID) _
        'AndAlso IcTag.szUID <> LastTag.szUID Then
        If Not String.IsNullOrEmpty(IcTag.szLotNo) _
            AndAlso IcTag.szLotNo <> LastTag.szLotNo Then

            LastTag = IcTag

            'If IcTag.OnHoldSt = OnHoldStatus.OnHold Then
            '    PutLog(Me.ToString, txtOptNoStt.Text, "ICタグセット、保留中")
            'Else
            Select Case IcTag.Status
                Case TagProcessStatus.Ready
                    PutLog(Me.ToString, txtOptNoStt.Text, "ICタグセット、着工準備")
                Case TagProcessStatus.Processing
                    PutLog(Me.ToString, txtOptNoStt.Text, "ICタグセット、着工中")
                Case TagProcessStatus.ManufComplete
                    PutLog(Me.ToString, txtOptNoStt.Text, "ICタグセット、製造完成")
            End Select
            'End If
            '別のロットの為治工具テーブルをクリアしておく
            m_dtMat.Clear()
            '照合結果のクリア
            ClearCollCells()
            m_TagStatus = TagStatus.TagSet

            LastTag = IcTag

            'Timer1.Start()
            m_ProcessStatus = ProcessStatus.TagSet

            '組立ロットNo.（共通）の場合、ステータス制御
            If txtData.Name.Equals("txtLotNo") Then
                RaiseEvent ProcessStatusChanged(Me, New EventArgs)
            Else
                Me.Cursor = Cursors.WaitCursor
                ShowBsiteWaiting()
                'タグデータをB-siteと同期する
                If inputLotType = INPUTLOTTYPE_DIFF Then
                    '>> 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
                    For Each tData In GroupID.Select(Function(item, i) New With {item, i})
                        IcTag = tData.item
                        SyncLotInfo()
                        If IcTag.iInput <> 0 Then '小LOT统合 2021/8/25 miaojf
                            GroupID(tData.i) = IcTag
                        End If
                    Next
                    '小LOT统合 2021/8/25 miaojf begin
                    Dim GroupIDLen As Integer = 0
                    For i As Integer = 0 To GroupID.Length - 1
                        If GroupID(i).iInput <> 0 Then
                            GroupIDLen += 1
                        End If
                    Next
                    ReDim Preserve GroupID(GroupIDLen - 1)
                    '小LOT统合 2021/8/25 miaojf end
                    '<< 20810320 大賀 No105 GroupKeyのProcCodeが更新されない
                    IcTag = GroupID(0)
                Else
                    SyncLotInfo()
                End If
                lblWait.Visible = False
                Me.Enabled = True
                Me.Cursor = Cursors.Default

                'ICタグでデータを取得
                '>>20180117 大賀  RSB確認結果一覧No53
                'GetDataByIcTag()
                '<<20180117 大賀  RSB確認結果一覧No53
                RaiseEvent ProcessStatusChanged(Me, New EventArgs) '苗 GROUP ID 修正 2018/1/12　
            End If
            '<<20180111 兪

        End If
        m_fIsGettingData = False
    End Sub
    '<<20170714

    'ICタグのデータで画面を設定する
    Protected Sub SetFromTag()
        SyncLotInfo() 'ADD 苗 2018/01/17

        'UPD 苗 2018/1/25　GroupID時、組立ロット:空白 BEGIN
        If inputLotType = INPUTLOTTYPE_DIFF Then
            lblLotNo.Text = String.Empty
        Else
            lblLotNo.Text = IcTag.szLotNo
        End If
        'UPD 苗 2018/1/25　GroupID時、組立ロット:空白 END
        lblDiffLotNo.Text = IcTag.szDifLotNo
        lblEquipID.Tag = IcTag.szEquipID
        Dim szTagProcCD As String = IcTag.szProcsCD


        'ロットNoを設定
        lotNo = SelectLotNo()

        '工程フロー
        ShowProcFlow()

        '>>20170717
        'If IcTag.Status = TagProcessStatus.Ready Then
        lblProcessCD.Text = szTagProcCD
        lblProcessCD.Tag = szTagProcCD
        SetTitle() 'ADD 苗 2018/1/19 
        Dim PrcsCode As clsDbLotInfo.ProcessCode
        PrcsCode = m_cLotInfo.GetProcessCD(lblLotNo.Text)
        lblNextProcs.Text = PrcsCode.szNextName
        'Else
        '    Dim PrcsCode As clsDbLotInfo.ProcessCode
        '    PrcsCode = m_cLotInfo.GetProcessCD(lblLotNo.Text)
        '    lblProcessCD.Text = PrcsCode.szNowProcess
        '    lblProcessCD.Tag = szTagProcCD
        '    lblNextProcs.Text = PrcsCode.szNextName
        'End If
        '<<20170717

        '投入数
        If m_IsHolding = OnHoldStatus.Solved Then
            lblInputCnt.Text = IcTag.iInput.ToString
        Else
            '>>20180112 佐川
            Dim count As Double = 0
            For Each tData In GroupID
                'UPD 苗 2018/1/27 BEGIN
                If tData.iFinish <> 0 Then
                    count += tData.iFinish
                Else
                    count += tData.iInput
                End If
                'UPD 苗 2018/1/27　BEGIN
            Next
            'UPD 苗 2018/1/17 BEGIN
            If inputLotType = INPUTLOTTYPE_DIFF Then
                lblInputCnt.Text = count.ToString
            Else
                lblInputCnt.Text = IcTag.iFinish
            End If
            'lblInputCnt.Text = count.ToString
            'UPD 苗 2018/1/17 END

            '<<20180112 佐川
        End If

        '×印数
        lblInputCross.Text = IcTag.iCross.ToString
        '×印枚数
        lblInputCrossFrm.Text = inputCrossPcbCnt
        'Qフラグ
        If IcTag.fQflag Then
            btnQflag.BackColor = ERROR_INIT_COLOR
            btnQflag.Tag = True
        Else
            btnQflag.BackColor = Drawing.SystemColors.Control
            btnQflag.UseVisualStyleBackColor = True
            btnQflag.Tag = False
        End If
        'Checkフラグ
        If IcTag.fCheckflag Then
            btnChecked.Tag = IcTag.fCheckflag
            btnChecked.BackColor = Color.Lime
        Else
            btnChecked.BackColor = Drawing.SystemColors.Control
            btnChecked.UseVisualStyleBackColor = True
            btnChecked.Tag = False
        End If
        '保留
        m_IsHolding = IcTag.OnHoldSt

        '完成数
        If m_IsHolding = OnHoldStatus.Solved AndAlso
            IcTag.Status = TagProcessStatus.Ready Then
            lblCompleteCnt.Text = "0"
        Else
            If IcTag.Status = TagProcessStatus.Ready Then
                lblCompleteCnt.Text = "0"
            Else
                Dim iFailed As Integer = 0
                Dim iCross As Integer = 0
                If IsNumeric(lblFailedCnt.Text) Then
                    iFailed = CInt(lblFailedCnt.Text)
                End If
                If IsNumeric(lblCrossCnt.Text) Then
                    iCross = CInt(lblCrossCnt.Text)
                End If
                lblCompleteCnt.Text = CInt(lblInputCnt.Text) - iFailed '- iCross 'UPD 苗 2018/2/8
            End If
        End If
        '>>20171202 兪
        lblFailedCnt.Text = "0"
        If fAutoX Then
            lblCrossCnt.Text = "0"
            lblCrossPcbCnt.Text = "0"
        Else
            'UPD 苗 2018/1/11 BEGIN
            lblCrossCnt.Text = IcTag.iCross.ToString 'String.Empty
            lblCrossPcbCnt.Text = inputCrossPcbCnt 'String.Empty
            'UPD 苗 2018/1/11 END
        End If
        '<<20171202 兪
        Call setJyokenData()

        For Each drJyoken In dtJyokenData.Rows
            ' 製造条件からWAFER LOTNOを取得
            If drJyoken("KOMOKUNAME").Equals("WAFER LOTNO") And
                               drJyoken("KOTEI").Equals("LOTINFO") Then
                lblWaferKeyNo.Text = drJyoken("KOMOKUDATA").ToString
                Exit For
            End If
        Next
        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
        If wf_read_flag = READ_WAFER Then
            lblInputFrm.Text = IcTag.waferNum.ToString

            ' デフォルト値の場合の対応を入れる
            If IcTag.waferNum <= WAFER_NUM_DEFAULT Then
                Dim getData = dtJyokenData.AsEnumerable.FirstOrDefault(Function(x) x("KOMOKUNAME").Equals("WAFER NUMBER"))
                If getData IsNot Nothing Then
                    lblInputFrm.Text = getData("KOMOKUDATA")
                End If
            End If
        Else
            lblInputFrm.Text = IcTag.iFrame.ToString
        End If
        '<<20180302 大賀 GroupKey入力時ウェハ枚数入力

        lblPcbCnt.Text = lblInputFrm.Text

        '画面ヘッダの型式のテーブルを取得する
        m_dtHeader = m_cEquipMat.GetHeader(lotNo, g_EQUIP_NO, lblProcessCD.Text, DateTime.Now.ToString(DATE_TIME_FORMAT_DB)) 'UPD 苗 2018/1/19 装置No.の対応
        If m_dtHeader.Rows.Count <= 0 Then
            m_dtHeader.Rows.Add()
        End If

        '工程CD
        m_MoveInCheck = True
        m_fProcessCheck = CheckProcsCD()
        If Not m_fProcessCheck Then
            'TimerTag.Stop()
            m_MoveInCheck = False

            If LotProcNonConformityMSG = True Then
                MsgBox(getMsgStr("MSG00025"))
            Else
                initializForm()
                btnLotTxt.PerformClick()
                Me.Refresh()
            End If
            Exit Sub
        Else
            If AProcCD() <> "" AndAlso IcTag.szProcsCD.Equals(AProcCD) Then
                Dim FormName As String = "正确的工程画面(" & IcTag.szProcsCD & ")"
                Select Case AProcCD()
                    Case PROC_CD_DBA
                        FormName = "DB全检画面"
                    Case PROC_CD_MOLDA
                        FormName = "MD全检画面"
                    Case PROC_CD_WBA
                        FormName = "Atlas的A42工程画面"
                End Select

                MsgBox(IcTag.szLotNo & " 请使用 " & FormName & " 进行处理。")
                m_MoveInCheck = False
                Exit Sub
            End If

        End If

        If m_fProcessCheck Then
            If Not IsBsiteMulti() Then
                m_fProcessCheck = CheckEquipID()
                If Not m_fProcessCheck Then
                    MsgBox(getMsgStr("MSG00041"))
                End If
            End If
        End If

    End Sub
    Protected m_MoveInCheck As Boolean = True

    Private Sub dgvFlow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvFlow.Click
        dgvFlow.ClearSelection()
    End Sub
#End Region

#Region "ICタグ書込"
    Private m_fIsWriting As Boolean = False
    Protected Function TagWriteBack(ByVal tagDat As TagData, Optional ByVal fIsRewrite As Boolean = False) As Boolean
        Static fIsRetry As Boolean
        m_fIsWriting = True
        TagWriteBack = False

        'Dim fTimer As Boolean = TimerTag.Enabled
        TimerTag.Stop()
        Dim dataWrite As New List(Of Byte)
        '組立Lot No
        Dim szLotNo As String = FixCharSpace(tagDat.szLotNo, LOT_NO_LENGTH)
        dataWrite.AddRange(StringToBytes(szLotNo))
        '拡散Lot No
        Dim szDifLot As String = FixCharSpace(tagDat.szDifLotNo, DIF_LOT_LENGTH)
        dataWrite.AddRange(StringToBytes(szDifLot))
        '状態
        dataWrite.Add(CInt(tagDat.Status))
        '装置ID
        Dim szEquipID As String = FixCharSpace(g_EQUIP_NO, EQUIP_NO_LENGTH) 'UPD 苗 2018/1/19 装置No.の対応
        dataWrite.AddRange(StringToBytes(szEquipID))
        '工程コード
        Dim szProcsCD As String = FixCharSpace(lblProcessCD.Tag, PROCS_CD_LENGTH)
        dataWrite.AddRange(StringToBytes(szProcsCD))
        '投入数
        dataWrite.AddRange(Int16ToBytes(tagDat.iInput))
        '完成数
        dataWrite.AddRange(Int16ToBytes(tagDat.iFinish))
        '不良数
        dataWrite.AddRange(Int16ToBytes(tagDat.iFailed))
        'フレーム数
        dataWrite.AddRange(Int16ToBytes(tagDat.iFrame))
        '×印数
        dataWrite.AddRange(Int16ToBytes(tagDat.iCross))
        'Qフラグ
        dataWrite.Add(CByte(CBool(btnQflag.Tag)))
        'Testフラグ
        dataWrite.Add(CByte(m_fTestFlg))
        'Checkフラグ
        dataWrite.Add(CByte(CBool(btnChecked.Tag)))
        '保留フラグ
        dataWrite.Add(CByte(m_IsHolding))

        '>>2018/1/30 佐川 キャリア交換対応
        icTagDataSet()
        '<<2018/1/30 佐川 キャリア交換対応

        'ダミーバイト
        Dim iDummy As Integer = dataWrite.Count Mod 4
        While iDummy > 0
            dataWrite.Add(CByte(0))
            iDummy -= 1
        End While
        'UIDを指定したタグにデータを書込む
        fIsRetry = True
        If Not fIsRewrite Then
            LastWriteTag = tagDat
            fIsRetry = False
        End If

        'Log
        Dim szOpt As String = String.Empty
        Dim szControl As String = Me.ToString
        Select Case tagDat.Status
            Case TagProcessStatus.Ready
                Select Case m_CmdType
                    Case CommandType.JO
                        szOpt = txtOptNoEnd.Text
                        szControl = btnTotalComp.ToString
                    Case CommandType.JC
                        szOpt = txtOptNoStt.Text
                        szControl = btnCancel.ToString
                End Select
            Case TagProcessStatus.Processing
                szOpt = txtOptNoStt.Text
            Case TagProcessStatus.ManufComplete
                szOpt = txtOptNoEnd.Text
                szControl = btnManufComp.ToString
        End Select

        m_fTagWriteFailed = True
        '/==============================/

        With IcTag
            'l_lotdataにデータを書き込み
            If m_cEquipMat.UpdateL_LotData(IcTag) <= 0 Then
                PutLog("ICタグ書込み失敗", szOpt, "")
                IcTagWriteFailed(szControl, szOpt, "L_LOTDATA")
            End If
        End With
        '/==============================/
        'g_cRFID.ClearData()
        'データ書込み
        'Dim wrRslt As clsRfidTag.WriteError = g_cRFID.WriteData(dataWrite.ToArray, tagDat.szUID)
        'If wrRslt = clsRfidTag.WriteError.OK Then
        '    TagWriteBack = True
        '    With IcTag
        '        Dim sztagData As String = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{11},{12}", _
        '                                  .szLotNo, .szDifLotNo, .Status, .szEquipID, .szProcsCD, _
        '                                  .iInput, .iFinish, .iFailed, .iFrame, .iCross, .fQflag, .fCheckflag, .fTestflag)
        '        PutLog(szControl, szOpt, "ICタグ書込み成功 データ:" & sztagData)
        '    End With
        'Else
        '    Dim szErr As String
        '    Select Case wrRslt
        '        Case clsRfidTag.WriteError.NACK
        '            szErr = "タグリーダがNACKを返した"
        '        Case clsRfidTag.WriteError.NoTag
        '            szErr = "ICタグがない"
        '        Case clsRfidTag.WriteError.TagReaderFailed
        '            szErr = "タグリーダエラー"
        '        Case clsRfidTag.WriteError.TimeOut
        '            szErr = "応答待ちタイムアウト"
        '        Case Else
        '            szErr = ""
        '    End Select
        '    If fIsRewrite Then
        '        PutLog(szControl, szOpt, "ICタグ書込み失敗:" & szErr)
        '        IcTagWriteFailed(szControl, szOpt, szErr)
        '    Else
        '        PutLog(szControl, szOpt, "ICタグ書込み失敗:" & szErr & "-->自動リトライ")
        '        TagWriteBack(LastWriteTag, True)
        '    End If
        'End If
        PutLog("タグデータ", szOpt, "")

        m_fIsWriting = False
    End Function

    'Private Sub WaitForTag(Optional ByVal iInerval As Integer = 120)
    '    While (g_SerialPort.BytesToRead > 0)
    '        'Debug.Print("Read")
    '        DataReceive(g_SerialPort, g_SerialArg)
    '        m_cRFID.WaitToWrite(iInerval)
    '    End While
    'End Sub

    Private Sub IcTagWriteFailed(ByVal szControl As String, ByVal szOpt As String, ByVal szErr As String)

        Select Case MsgBox(getMsgStr("MSG00069") & szErr,
                           MsgBoxStyle.RetryCancel)
            Case MsgBoxResult.Cancel
                PutLog(szControl, szOpt, getMsgStr("MSG00070"))
                m_szResult = NG
                m_ProcessStatus = ProcessStatus.Failed
                RaiseEvent ProcessStatusChanged(Me, New EventArgs)
            Case MsgBoxResult.Retry
                PutLog(szControl, szOpt, getMsgStr("MSG00071"))
                'g_cRFID.ClearData()
                TagWriteBack(LastWriteTag)
                'Case MsgBoxResult.Ignore
                '    PutLog(szControl, szOpt, "ICタグ書込み失敗-->無視")
        End Select
    End Sub
#End Region

#Region "B-site受信"

    '********************************************************************************
    '*  コマンドタイマ処理
    '********************************************************************************
    Protected Sub intTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles intTimer.Tick
        Dim szResult As String = String.Empty
        'Dim dtResult As DataTable
        intTimer.Enabled = False

        m_iTimerCnt = m_iTimerCnt + 1
        'タイムアウト処理
        If m_iTimerCnt >= m_iTimeOutCnt Then
            Select Case m_CmdType
                Case CommandType.JI
                    PutLog(Me.ToString, txtOptNoStt.Text, "着工開始、b-site計上タイムアウト")
                Case CommandType.JO
                    PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "計上完成、b-site計上タイムアウト")
                Case CommandType.JC
                    PutLog(btnCancel.ToString, txtOptNoStt.Text, "ロットキャンセル、b-site計上タイムアウト")
                Case CommandType.JM
                    PutLog(Me.ToString, txtOptNoStt.Text, "材料セットアップ、b-site計上タイムアウト")
            End Select
            MsgBox(getMsgStr("MSG00026"))
            Me.Cursor = Cursors.Default
            panelHeader.Enabled = True
            panelHeader2.Enabled = True
            lblWait.Visible = False
            Me.Enabled = True

            CommandFailed()
            '>>20170717
            If m_fIcTagUsed Then
                TimerTag.Start()
            End If
            '<<20170717
            Exit Sub
        Else
            '結果が出来ていないならこのまま待つ
            If outHeader Is Nothing Then
                intTimer.Enabled = True
                Exit Sub
            End If
            szResult = outHeader.Status

            '結果が出来ていないならこのまま待つ
            If String.IsNullOrEmpty(szResult) Then
                intTimer.Enabled = True
                Exit Sub
            End If
            nextProcCode = IcTag.szProcsCD
            '>>20180328 大賀 No122 DBサーバ時刻を使用する
            'If outHeader.LotInf Is Nothing Or outLotInfo Is Nothing Then
            '    serverTime = Now()
            'Else
            '    If Not DateTime.TryParse(outHeader.LotInf.LastActivityDate, serverTime) Then
            '        serverTime = Now()
            '    End If
            'End If
            serverTime = m_cData.GetServerTime()
            '<<20180328 大賀 No122 DBサーバ時刻を使用する

            Me.Enabled = True

            m_szResult = szResult
            'b-site結果
            Select Case szResult
                Case STS_SUCCESS 'コマンド種類によって処理を選択する
                    'ViewLotService情報取得
                    Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
                    param.Name = lotNo
                    Dim clientStr As String = GetBsiteClientString()
                    Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
                    outLotInfo = viewLotServiceInfo.LotInf

                    If viewLotServiceInfo.LotInf Is Nothing Then
                        '>>20180112 佐川
                        ShowBsiteResultGroupKey(NG)
                        '<<20180112 佐川
                        CommandFailed()
                    ElseIf viewLotServiceInfo.Header.Status.Equals(STS_ERROR) Then
                        '>>20180112 佐川
                        ShowBsiteResultGroupKey(NG)
                        '>>20180112 佐川
                        CommandFailed()
                    Else
                        If outLotInfo.Operation IsNot Nothing AndAlso
                                                    outLotInfo.Operation.Trim().Length > 0 Then
                            '次工程の工程コードを取得 maruyama@tmc
                            Select Case m_CmdType
                                Case CommandType.JI
                                    '着工時は現工程をセット
                                    nextProcCode = outLotInfo.Operation
                                Case CommandType.JO
                                    '完成時は次工程をセット maruyama 2017/7/26
                                    Dim dtNextProcCode = m_cData.GetNextProcCode(lblLotNo.Text, viewLotServiceInfo.LotInf.Operation)
                                    If dtNextProcCode.Rows.Count > 0 Then
                                        nextProcCode = dtNextProcCode.Rows(0)("POSTPROC")
                                    Else
                                        nextProcCode = viewLotServiceInfo.LotInf.Operation
                                    End If
                            End Select
                        End If

                        Select Case m_CmdType
                            Case CommandType.JI
                                PutLog(Me.ToString, txtOptNoStt.Text, "着工開始、b-site計上成功")
                                JiSuccess()
                            Case CommandType.JO
                                '保留でなければまずデータを更新
                                If Not m_cBsiteMess.CheckOnHold(m_szIP) Then
                                    PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "計上完成、b-site計上成功")
                                    JoSuccess()
                                End If
                            Case CommandType.JC
                                PutLog(btnCancel.ToString, txtOptNoStt.Text, "ロットキャンセル、b-site計上成功")
                                JcSuccess()
                            Case CommandType.JM
                                PutLog(Me.ToString, txtOptNoStt.Text, "材料セットアップ、b-site計上成功")
                                JmSuccess()
                        End Select
                        '>>20180112 佐川
                        If ShowBsiteResultGroupKey(OK) = DefectJudgement.HOLD Then
                            '<<20180112 佐川
                            HoldProcess()
                            Exit Select
                        End If
                        If m_CmdType = CommandType.JO AndAlso m_szResult.Equals(STS_SUCCESS) Then
                            CheckWarning()
                        End If
                    End If
                Case STS_WARNING
                    If m_CmdType = CommandType.JO Then
                        PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "b-site警告により計上失敗")
                        '>>20180112 佐川
                        Dim reslt As DefectJudgement = ShowBsiteResultGroupKey(WA)
                        '<<20180112 佐川
                        If reslt = DefectJudgement.HOLD Then
                            HoldProcess()
                            Exit Select
                        ElseIf reslt = DefectJudgement.WARNING Then
                            PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "強制完成コマンド送信")
                            '>>20180111 佐川
                            SendCommand(CommandType.JO, True, IcTag)
                            '<<20180111 佐川
                            Exit Sub
                        Else
                            PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "b-site警告を処理せずに終了")
                            CommandFailed()
                        End If
                    ElseIf m_CmdType = CommandType.JI Then
                        PutLog(btnTotalComp.ToString, txtOptNoStt.Text, "b-site警告により着工失敗")
                        '>>20180112 佐川
                        Dim reslt As DefectJudgement = ShowBsiteResultGroupKey(WA)
                        '<<20180112 佐川
                        If reslt = DefectJudgement.HOLD Then
                            HoldProcess()
                            Exit Select
                        ElseIf reslt = DefectJudgement.WARNING Then
                            PutLog(btnTotalComp.ToString, txtOptNoStt.Text, "強制着工コマンド送信")
                            '>>20180111 佐川
                            SendCommand(CommandType.JI, True, IcTag)
                            '<<20180111 佐川
                            Exit Sub
                        Else
                            PutLog(btnTotalComp.ToString, txtOptNoStt.Text, "b-site警告を処理せずに終了")
                            CommandFailed()
                        End If
                    Else
                        PutLog(btnTotalComp.ToString, "", "b-site返信異常により計上失敗")
                        '>>20180112 佐川
                        ShowBsiteResultGroupKey(NG)
                        '<<20180112 佐川
                        CommandFailed()
                    End If
                Case STS_ERROR
                    Select Case m_CmdType
                        Case CommandType.JI
                            PutLog(Me.ToString, txtOptNoStt.Text, "着工開始、b-site計上失敗")
                        Case CommandType.JO
                            JoError()
                            PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "計上完成、b-site計上失敗")
                        Case CommandType.JC
                            PutLog(btnCancel.ToString, txtOptNoStt.Text, "ロットキャンセル、b-site計上失敗")
                        Case CommandType.JM
                            PutLog(Me.ToString, txtOptNoStt.Text, "材料セットアップ、b-site計上失敗")
                    End Select
                    '失敗メッセージ
                    '>>20180112 佐川
                    If ShowBsiteResultGroupKey(NG) = DefectJudgement.HOLD Then
                        '<<20180112 佐川
                        HoldProcess()
                        Exit Select
                    End If
                    CommandFailed()
            End Select

        End If
        Me.Enabled = True
        lblWait.Visible = False
        Me.Cursor = Cursors.Default
        panelHeader.Enabled = True
        panelHeader2.Enabled = True
        '>>20170717
        If m_fIcTagUsed Then
            TimerTag.Start()
        End If
        '<<20170717

        'Lot保留
        If m_IsHolding = OnHoldStatus.OnHold Then
            m_ProcessStatus = ProcessStatus.Hold
            RaiseEvent ProcessStatusChanged(Me, New EventArgs)
        End If

        If m_CmdType = CommandType.JO And doAProcMoveIn() Then
            Call AProcDoStartComplete()
        End If

        If m_CmdType = CommandType.JO And m_szResult = STS_SUCCESS Then
            '料盒单位流动的话，料盒完了后，就要把抽检记录里的着工料盒变成完工料盒
            If m_CmdType = CommandType.JO And isRackNoFlow() Then
                Call updateRCRackID()
            End If
            'ADD 2020/8/17 miaojf Ver.70
            '当bsite计上成功，且 已有等待执行的LN时，调用方法进行执行，执行完删除等待指令
            If AutoManualMode = 0 And NP_IU_RTN = True And IsNothing(WaitLnCommand) = False Then
                initializForm()
                Me.Refresh()
                CommandReceive(WaitLnCommand)
                WaitLnCommand = Nothing
            End If
        End If
        '------------------wb LN还没完，LC便发出，LD也收到------------
        If AutoManualMode = 0 And LN_COLSED = True And IsNothing(WaitLDCommand) = False Then
            Me.Refresh()
            CommandReceive(WaitLDCommand)
            WaitLDCommand = Nothing
        End If
        '-------------------------------------------------------------
    End Sub
    Overridable Sub JoError()
        ShowBsiteResultGroupKey(NG)
    End Sub
    Overridable Function doAProcMoveIn()
        Return False
    End Function
    ''' <summary>
    ''' B-siteからの返事を表示する
    ''' </summary>
    ''' <param name="szResult">OK/NG</param>
    ''' <remarks></remarks>
    Private Function ShowBsiteResult(ByVal szResult As String) As DefectJudgement
        'If m_fNeedVerif = False Then
        Dim frmResult As New frmBsiteResult(m_szIP, szResult)
        frmResult.StartPosition = FormStartPosition.CenterParent
        'B-site送信対応 結果引渡し
        frmResult.outHeader = outHeader
        frmResult.htMsgMst = htMsgMst
        'If frmResult.ShowDialog() = Windows.Forms.DialogResult.Retry Then
        '    ShowBsiteResult = DefectJudgement.WARNING
        'Else
        '    ShowBsiteResult = DefectJudgement.OK
        'End If

        If szResult = WA Then
            frmResult.btnResultOK.Text = htMsgMst("MSG00142")
        End If

        Select Case frmResult.ShowDialog()
            Case Windows.Forms.DialogResult.Retry
                ShowBsiteResult = DefectJudgement.WARNING
            Case Windows.Forms.DialogResult.Abort
                ShowBsiteResult = DefectJudgement.HOLD
            Case Else
                ShowBsiteResult = DefectJudgement.OK
        End Select

        'Else
        '    ShowBsiteResult = False
        'End If
    End Function

    '>>20180112 佐川
    ''' <summary>
    ''' B-siteからの返事を表示するGroupKey対応
    ''' </summary>
    ''' <param name="szResult">OK/NG</param>
    ''' <remarks></remarks>
    Private Function ShowBsiteResultGroupKey(ByVal szResult As String) As DefectJudgement
        Dim frmResult As New frmBsiteResult(m_szIP, szResult)
        frmResult.StartPosition = FormStartPosition.CenterParent

        'B-site送信対応のサイズ変更
        If Not outHeader.ResultCode.Length() = GroupID.Length() Then
            ReDim Preserve outHeader.ResultCode(GroupID.Length() - 1)
            ReDim Preserve outHeader.ResultMessage(GroupID.Length() - 1)
        End If
        'B-site送信対応 結果引渡し
        frmResult.outHeader = outHeader
        frmResult.htMsgMst = htMsgMst

        If szResult = WA Then
            frmResult.btnResultOK.Text = htMsgMst("MSG00142")
        End If

        If IsNothing(frmGroupKeyResultMsg) Then
            frmGroupKeyResultMsg = frmResult
            frmGroupKeyResultMsg.outHeader.ResultMessage(0) = outHeader.ResultMessage(0) + "(" + outHeader.LotName + ")"
            frmGroupKeyResultMsg.htMsgMst = htMsgMst
        Else
            frmGroupKeyResultMsg.outHeader.ResultCode(execCount) = outHeader.ResultCode(0)
            frmGroupKeyResultMsg.outHeader.ResultMessage(execCount) = outHeader.ResultMessage(0) + "(" + outHeader.LotName + ")"
            'ウィンドウの変更、OK以外が存在する場合は優先する。
            '>>20180116 佐川
            If szResult = WA Then
                frmGroupKeyResultMsg.btnResultOK.Text = htMsgMst("MSG00142")
            End If
            If Not szResult = OK Then
                frmGroupKeyResultMsg.szResultData = szResult
            End If
            '<<20180116 佐川
        End If
        If execCount = GroupID.Length() - 1 Then
            Select Case frmGroupKeyResultMsg.ShowDialog()
                Case Windows.Forms.DialogResult.Retry
                    ShowBsiteResultGroupKey = DefectJudgement.WARNING
                Case Windows.Forms.DialogResult.Abort
                    ShowBsiteResultGroupKey = DefectJudgement.HOLD
                Case Else
                    ShowBsiteResultGroupKey = DefectJudgement.OK
            End Select
        Else
            ShowBsiteResultGroupKey = DefectJudgement.OK
        End If

    End Function
    '<<20180112 佐川

    Private Function CheckWarning() As DefectJudgement
        '>>20170718 不良率管理値チェック機能を外す
        'Dim dtError As New DataTable
        'If m_IsHolding <> OnHoldStatus.Solved Then
        '    dtError = Me.dtError
        'End If
        'If dtError.Rows.Count > 0 Then
        '    Dim i As Integer
        '    Dim szCata() As String = New String(dtError.Rows.Count - 1) {}
        '    For i = 0 To dtError.Rows.Count - 1
        '        szCata(i) = dtError.Rows(i)("コード")
        '    Next
        '    Dim szCustmonerShort As String = m_cData.GetCustomerShort(lblLotNo.Text)
        '    If String.IsNullOrEmpty(szCustmonerShort) Then
        '        szCustmonerShort = GetCustomerShort()
        '    End If

        '    If (NG & NG).Equals(szCustmonerShort) Then
        '        Return DefectJudgement.ERR
        '    End If

        '    '履歴テーブル変更対応 2017.6.21
        '    'With dtData.Rows(0)
        '    'Dim dtWarning As DataTable = m_cLotDefect.CheckWarning(IcTag.szProcsCD,
        '    '                                                       .Item("KIND_NM").ToString.Replace(" ", ""),
        '    '                                                       szCustmonerShort,
        '    '                                                       .Item("SHAPE").ToString.Replace(" ", ""),
        '    '                                                       szCata)
        '    Dim dtWarning As DataTable = m_cLotDefect.CheckWarning(IcTag.szProcsCD,
        '                                                               lblkindNm.Text.ToString.Replace(" ", ""),
        '                                                               szCustmonerShort,
        '                                                               lblShape.Text.ToString.Replace(" ", ""),
        '                                                               szCata)
        '    'Dim dtWarning As DataTable = m_cLotDefect.CheckWarning("D700", "TDF047GP-Z", "FDT", "LQFP1010- 64 CU", szCata)
        '    'Dim dtWarning As DataTable = m_cLotDefect.CheckWarning("D700", "", "FDT", "LQFP1010- 64 CU", szCata)

        '    If dtWarning.Rows.Count > 0 Then

        '        Dim dsVerif As New DataSet
        '        Dim dtResult1 As New DataTable("Result1")
        '        Dim dtResult2 As New DataTable("Result2")

        '        dtWarning.DefaultView.RowFilter = "OVER_UNDER1 <> '-' AND THRESHOLD1 <> '-' AND IS_EXCLUDED=0"
        '        Dim dtWarning1 As DataTable = dtWarning.DefaultView.ToTable("WARNING1")
        '        dtWarning.DefaultView.RowFilter = "OVER_UNDER1 <> '-' AND THRESHOLD1 <> '-' AND IS_EXCLUDED=1"
        '        Dim dtWarningTmp1 As DataTable = dtWarning.DefaultView.ToTable

        '        Dim drAll() As DataRow = dtWarning1.Select("CATA_CD='ALL'")
        '        For Each drNG As DataRow In dtError.Rows
        '            For Each dr As DataRow In drAll
        '                Dim drNew As DataRow = dtWarning1.NewRow
        '                For i = 0 To dtWarning1.Columns.Count - 1
        '                    drNew(i) = dr(i)
        '                Next
        '                drNew("CATA_CD") = drNG("コード")
        '                dtWarning1.Rows.Add(drNew)
        '            Next

        '            Dim fIsIncluded As Boolean = False
        '            Dim fIsAll As Boolean = False
        '            For i = 0 To dtWarningTmp1.Rows.Count - 1
        '                If drNG("コード") = dtWarningTmp1.Rows(i)("CATA_CD") Then
        '                    fIsIncluded = True
        '                    Exit For
        '                End If
        '            Next
        '            If fIsIncluded = False Then
        '                For Each dr As DataRow In dtWarningTmp1.Rows
        '                    Dim drNew As DataRow = dtWarning1.NewRow
        '                    For i = 0 To dtWarning1.Columns.Count - 1
        '                        drNew(i) = dr(i)
        '                    Next
        '                    drNew("CATA_CD") = drNG("コード")
        '                    dtWarning1.Rows.Add(drNew)
        '                Next
        '            End If
        '        Next

        '        dtWarning.DefaultView.RowFilter = "OVER_UNDER2 <> '-' AND THRESHOLD2 <> '-' AND IS_EXCLUDED=0"
        '        Dim dtWarning2 As DataTable = dtWarning.DefaultView.ToTable("WARNING2")
        '        dtWarning.DefaultView.RowFilter = "OVER_UNDER2 <> '-' AND THRESHOLD2 <> '-' AND IS_EXCLUDED=1"
        '        Dim dtWarningTmp2 As DataTable = dtWarning.DefaultView.ToTable

        '        drAll = dtWarning2.Select("CATA_CD='ALL'")
        '        For Each drNG As DataRow In dtError.Rows
        '            For Each dr As DataRow In drAll
        '                Dim drNew As DataRow = dtWarning2.NewRow
        '                For i = 0 To dtWarning2.Columns.Count - 1
        '                    drNew(i) = dr(i)
        '                Next
        '                drNew("CATA_CD") = drNG("コード")
        '                dtWarning2.Rows.Add(drNew)
        '            Next

        '            Dim fIsIncluded As Boolean = False
        '            For i = 0 To dtWarningTmp2.Rows.Count - 1
        '                If drNG("コード") = dtWarningTmp2.Rows(i)("CATA_CD") Then
        '                    fIsIncluded = True
        '                    Exit For
        '                End If
        '            Next
        '            If fIsIncluded = False Then
        '                For Each dr As DataRow In dtWarningTmp2.Rows
        '                    Dim drNew As DataRow = dtWarning2.NewRow
        '                    For i = 0 To dtWarning2.Columns.Count - 1
        '                        drNew(i) = dr(i)
        '                    Next
        '                    drNew("CATA_CD") = drNG("コード")
        '                    dtWarning2.Rows.Add(drNew)
        '                Next
        '            End If
        '        Next

        '        dsVerif.Tables.Add(dtError)
        '        dsVerif.Tables.Add(dtWarning1)
        '        dsVerif.Tables.Add(dtWarning2)
        '        dsVerif.Tables.Add(dtResult1)
        '        dsVerif.Tables.Add(dtResult2)

        '        dtResult1.Load(dtWarning1.CreateDataReader)
        '        dtResult2.Load(dtWarning2.CreateDataReader)

        '        Dim relation1 As New DataRelation("Relation1", dtError.Columns("コード"), dtResult1.Columns("CATA_CD"), False)
        '        dsVerif.Relations.Add(relation1)
        '        Dim relation2 As New DataRelation("Relation2", dtError.Columns("コード"), dtResult2.Columns("CATA_CD"), False)
        '        dsVerif.Relations.Add(relation2)

        '        Dim szParent As String = "Convert(Parent.数量, 'System.Decimal') / Convert(" & lblInputCnt.Text & ", 'System.Decimal') * 100"

        '        Dim szExpOver1 As String = "IIF( " & szParent & " > Convert(THRESHOLD1, 'System.Decimal'), OUTPUT_TYPE, '-')"
        '        Dim szExpUnder1 As String = "IIF( " & szParent & " < Convert(THRESHOLD1, 'System.Decimal'), OUTPUT_TYPE, '-')"
        '        Dim szExpJudg1 As String = "IIF(OVER_UNDER1='1' AND OVER_UNDER1<>'-', " & szExpOver1 & ", " & szExpUnder1 & " )"

        '        Dim szExpOver2 As String = "IIF( " & szParent & " > Convert(THRESHOLD2, 'System.Decimal'), OUTPUT_TYPE, '-')"
        '        Dim szExpUnder2 As String = "IIF( " & szParent & " < Convert(THRESHOLD2, 'System.Decimal'), OUTPUT_TYPE, '-')"
        '        Dim szExpJudg2 As String = "IIF(OVER_UNDER2='1' AND OVER_UNDER2<>'-', " & szExpOver2 & ", " & szExpUnder2 & " )"

        '        dtResult1.Columns.Add("CATA", "".GetType, "Parent." & "不良内容")
        '        dtResult1.Columns.Add("RATE", 0.GetType, szParent)
        '        dtResult1.Columns.Add("RESULT", "".GetType, szExpJudg1)

        '        dtResult2.Columns.Add("CATA", "".GetType, "Parent." & "不良内容")
        '        dtResult2.Columns.Add("RATE", 0.GetType, szParent)
        '        dtResult2.Columns.Add("RESULT", "".GetType, szExpJudg2)

        '        Dim lstMsgType As New List(Of String)
        '        Dim sbMsg As New StringBuilder

        '        For i = 0 To 8
        '            Dim drHold() As DataRow = dtResult2.Select(String.Format("RESULT='{0}'", i))
        '            If drHold.Length > 0 Then
        '                lstMsgType.Add(i.ToString)
        '                sbMsg.AppendLine(WarningMsg(i))

        '            End If
        '        Next
        '        If lstMsgType.Count > 0 Then
        '            'message表示
        '            MsgBox(sbMsg.ToString)
        '            MsgBox(sbMsg.ToString)
        '            If PROC_CD_INSP.Equals(IcTag.szProcsCD) Then
        '                CommandFailed()
        '                Return DefectJudgement.WARNING
        '            Else
        '                Return DefectJudgement.HOLD
        '            End If
        '        End If

        '        For i = 0 To 8
        '            Dim drWarning() As DataRow = dtResult1.Select(String.Format("RESULT='{0}'", i))
        '            If drWarning.Length > 0 Then
        '                lstMsgType.Add(i.ToString)
        '                sbMsg.AppendLine(WarningMsg(i))

        '            End If
        '        Next
        '        If lstMsgType.Count > 0 Then
        '            'message表示
        '            MsgBox(sbMsg.ToString)
        '            Return DefectJudgement.WARNING
        '        End If

        '    End If
        '    'End With

        'End If
        Return DefectJudgement.OK
    End Function

    Private Function IsBsiteOnHold() As Boolean
        Dim InViewLot As New InSiteWebService.InViewLot
        Dim OutViewLot As New InSiteWebService.OutLotStd

        InViewLot.Name = lotNo
        Dim clientStr As String = GetBsiteClientString()
        OutViewLot = ViewLotServiceGet(InViewLot, clientStr)
        Return OutViewLot.LotInf.IsOnHold
    End Function

    'Private Function GetCustomerShort() As String
    '    Dim InParam As New InSiteWebService.InQuery
    '    Dim OutParam As New InSiteWebService.OutQuery
    '    Dim strSQL As String = ""

    '    strSQL = " select "
    '    strSQL &= " main.lotname, "
    '    strSQL &= " main.operationname, "
    '    strSQL &= " main.txndate, "
    '    strSQL &= " main.qty, "
    '    strSQL &= " pro.customercategory "
    '    strSQL &= " from lth_main main  "
    '    strSQL &= " left join product pro  "
    '    strSQL &= " on main.product = pro.productname  "
    '    strSQL &= " and main.productrev = pro.productrevision   "
    '    strSQL &= " where "
    '    strSQL &= "lotname = " & Chr(39) & lblLotNo.Text & Chr(39) & " "
    '    strSQL &= " and operationname in (" & Chr(39) & "Q200" & Chr(39) & "," & Chr(39) & "P960" & Chr(39) & ") "
    '    'strSQL &= " and operationname = " & Chr(39) & lblProcessCD.Text & Chr(39) & " "
    '    strSQL &= " and txn = " & Chr(39) & "MoveOut" & Chr(39) & " "
    '    InParam.query = strSQL
    '    OutParam = QueryServiceExecute(InParam)

    '    If IsNothing(OutParam.table) Then
    '        GetCustomerShort = String.Empty
    '    Else
    '        GetCustomerShort = OutParam.table(0).values(4)
    '    End If
    'End Function

    Private Function GetCustomerShort() As String
        Dim InParam As New InSiteWebService.InQuery
        Dim OutParam As New InSiteWebService.OutQuery
        Dim strSQL As String = ""

        strSQL = " select "
        strSQL &= " lotname, "
        strSQL &= " operation, "
        strSQL &= " qty, "
        strSQL &= " customercategory "
        strSQL &= " from wip "
        strSQL &= " where "
        strSQL &= "lotname = " & Chr(39) & lblLotNo.Text & Chr(39) & " "

        InParam.query = strSQL
        OutParam = QueryServiceExecute(InParam)

        If IsNothing(OutParam.table) Then
            GetCustomerShort = NG & NG
        Else
            GetCustomerShort = OutParam.table(0).values(1)
        End If
    End Function

    ''' <summary>
    ''' B-siteからの返事はNGの場合
    ''' </summary>
    ''' <remarks></remarks>
    Overridable Sub CommandFailed()
        m_ProcessStatus = ProcessStatus.Failed
        RaiseEvent ProcessStatusChanged(Me, New EventArgs)
    End Sub
#End Region

#Region "データベース"
    'Lot Noでデータベースからデータを取得する
    Overridable Sub GetDataByIcTag()

    End Sub

    ''' <summary>
    ''' 治工具、材料データ保存
    ''' </summary>
    ''' <param name="szBeginTime"></param>
    ''' <remarks></remarks>
    Overridable Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean
        If m_cEquipMat.UpdateEquipMatCom(IcTag.szEquipID, g_EQUIP_NO, IcTag.szLotNo,'UPD 苗 2018/1/19 装置No.の対応
                                     m_cIdohyo.EquipInfo.szSysEquipID,
                                     m_cIdohyo.EquipInfo.szEquipNo,
                                     lblProcessCD.Text, m_dtMat,
                                     szBeginTime, txtOptNoStt.Text, m_szTable, m_dtHeader) < 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    'ベークデータ保存
    Overridable Sub SaveEquipMat(ByRef szBeginTime As DateTime, ByRef lotNo As Integer)

    End Sub

    ' Multiサービスを使用する場合はOverrideする
    Overridable Function IsBsiteMulti() As Boolean
        Return False
    End Function

    Overridable Function AProcStartCompleteFLG() As Boolean
        Return False
    End Function
    Overridable Function AProcCD() As String
        Return ""
    End Function
    Overridable Function doChkFrameID() As Boolean
        Return True
    End Function

    ' Multi報告完成数
    Protected mMultiTotalFrame As String
    ' 作業場所
    Protected mLocationCode As String
    ' Multi計上の1,2振分
    Protected mMultiExecCheck As Boolean

    'コマンド発信
    Protected Sub SendCommand(ByVal OP As CommandType, Optional ByVal fIsForced As Boolean = False, Optional ByVal tagData As TagData = Nothing)
        Dim strMPCCommand As String = ""
        '>>20180111 兪
        If IsNothing(tagData.szLotNo) Then 'UPD 苗 2018/1/24 tagDataの値が無くても、Nothingではない
            tagData = IcTag
        End If
        TimerTag.Stop()
        '>>20170717
        Dim szLotNoSend As String = FixCharSpace(tagData.szLotNo, 30)
        Dim szDifLotSend As String = FixCharSpace(tagData.szDifLotNo, 30)
        '<<20180111 兪
        Dim szKouteiCDSend As String = FixCharSpace(lblProcessCD.Text, 10)
        'Dim szFactorySend As String = FixCharSpace(String.Empty, 3)
        'Dim szOperatorStartSend As String = FixCharSpace(txtOptNoStt.Text, 20)
        'Dim szOperatorEndSend As String = FixCharSpace(txtOptNoEnd.Text, 20)
        'Dim szTypeSend As String = FixCharZero(g_CURRENT_EQUIP_TYPE, 4)
        Dim szEquipIdSend As String = FixCharSpace(g_EQUIP_NO, 30) 'UPD 苗 2018/1/19 装置No.の対応
        'Dim szEquipNoSend As String = FixCharSpace(lblEquipID.Text, 30)
        Dim clientProcCd = GetBsiteClientString()

        If g_CURRENT_EQUIP_TYPE = DEF_ID_PULL Then
            szEquipIdSend = szEquipIdSend.Replace("-A", "  ")
            'szEquipNoSend = szEquipNoSend.Replace("-A", "  ")
        End If

        Dim szCmdToSend As String
        Dim moveInWaferLot As Boolean = False

        If lblWait.Visible = False Then
            ShowBsiteWaiting()
            Threading.Thread.Sleep(100)
        End If
        'コマンド種類の選択
        Select Case OP
            Case CommandType.JI
                PutLog(Me.ToString, txtOptNoStt.Text, "b-site送信")
                '>>20180111 佐川
                'If inputLotType = INPUTLOTTYPE_DIFF Then
                '    szLotNoSend = szDifLotSend
                '    moveInWaferLot = True
                'End If
                '<<20180111 佐川
                If AutoManualMode <> 0 Then
                    Dim szCollTypeSend As String = "0"
                    Dim szMultiSend As String = "0"
                    Dim szForceSend As String = "0"
                    'Atlasサーバ送信
                    szCmdToSend = String.Format(CMD_NI, szLotNoSend, szKouteiCDSend, szEquipIdSend)
                    clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)
                End If
                ' ----- bSite送信実装 Start
                '>>20171109 兪
                If m_fIsLineEquip Then
                    '一貫機
                    Dim inputBsite As New InSiteWebService.InMoveInLine
                    Dim outputBsite As New InSiteWebService.OutMoveInLine
                    inputBsite.Employee = txtOptNoStt.Text  '開始作業者
                    inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                    inputBsite.Machine = g_EQUIP_NO         '装置No
                    inputBsite.Operation = m_szEndProcCD    '完成（予定）工程コード

                    outHeader = Nothing
                    outLotInfo = Nothing
                    outputBsite = MoveInServiceLine_Execute(inputBsite, clientProcCd)
                    '戻り情報を保持
                    outHeader = outputBsite.Header
                    outLotInfo = outputBsite.LotInf
                Else
                    outHeader = Nothing
                    outLotInfo = Nothing
                    If IsBsiteMulti() Then
                        Dim inputBsite As New InSiteWebService.InMoveInMultiMachine
                        Dim outputBsite As New InSiteWebService.OutMoveInMultiMachine
                        If txtOptNoStt.Text = "" Then txtOptNoStt.Text = UserNo
                        inputBsite.Employee = txtOptNoStt.Text      '開始作業者
                        inputBsite.Lot = szLotNoSend.Trim           'ロットNo
                        inputBsite.Machine = g_EQUIP_NO             '装置No
                        If Not String.IsNullOrEmpty(outWeekCode) Then
                            inputBsite.WeeklyCode = outWeekCode     '週コード
                        End If
                        If mLocationCode = "" Then
                            mLocationCode = (GetIniFile("EQUIP", "LocationCode", "ZB1-S42", g_szInitFileName))
                        End If
                        inputBsite.LocationCode = mLocationCode     '作業場所

                        outputBsite = MoveInMultiMachineService_Execute(inputBsite, clientProcCd)
                        '戻り情報を保持
                        outHeader = outputBsite.Header
                        outLotInfo = outputBsite.LotInf
                        mLocationCode = outLotInfo.LocationCode
                        PutIniFile("EQUIP", "LocationCode", mLocationCode, g_szInitFileName)
                    Else
                        Dim inputBsite As New InSiteWebService.InMoveIn
                        Dim outputBsite As New InSiteWebService.OutMoveIn
                        If txtOptNoStt.Text = "" Then txtOptNoStt.Text = UserNo
                        inputBsite.Employee = txtOptNoStt.Text  '開始作業者
                        inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                        inputBsite.Machine = g_EQUIP_NO         '装置No
                        inputBsite.IgnoreLimitTime = fIsForced   '強制着工
                        inputBsite.MoveInForWaferLot = moveInWaferLot   '拡散ロット着工
                        If Not String.IsNullOrEmpty(outWeekCode) Then
                            inputBsite.WeeklyCode = outWeekCode '週コード
                        End If

                        outputBsite = MoveInService_Execute(inputBsite, clientProcCd)
                        '戻り情報を保持
                        outHeader = outputBsite.Header
                        outLotInfo = outputBsite.LotInf
                    End If
                End If

                '<<20171109 兪
                'ADD MIAO 2019/10/1 BEGIN
                '---------MPCへ送信 BEGIN ------------
                If AutoManualMode = 0 Then
                    strMPCCommand = ""
                    Dim rtn As String = OK
                    Dim rtnIT As String = COMMAND_OK
                    If STS_SUCCESS.Equals(outHeader.Status) Then
                        rtn = OK
                        rtnIT = COMMAND_OK
                        LC_COMMAND = ""
                    Else
                        rtn = NG
                        rtnIT = COMMAND_NG

                    End If

                    'TODO：追加要
                    'NJコマンド
                    With IcTag
                        strMPCCommand = createStORCompCommandStr(COMMAND_NJ, rtn, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
                                            lblEquipID.Text, "", "", txtOptNoStt.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
                    End With
                    PutLog(Me.ToString, "sendCommand", strMPCCommand)
                    m_cEquipCommandControl.CommandSend(strMPCCommand)

                    'ITコマンド
                    'If LN_FLAG = True Then
                    sendResponseCommand(COMMAND_IT, rtnIT)
                    'End If

                Else
                    'Atlasサーバ送信
                    If STS_SUCCESS.Equals(outHeader.Status) Then
                        szCmdToSend = String.Format(CMD_NJ, szLotNoSend, szKouteiCDSend, szEquipIdSend, OK)
                    Else
                        szCmdToSend = String.Format(CMD_NJ, szLotNoSend, szKouteiCDSend, szEquipIdSend, NG)
                    End If
                    clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)
                End If
        '---------MPCへ送信 END ------------
        'ADD MIAO 2019/10/1 END
                ' ----- bSite送信実装 End<JO>
            Case CommandType.JO
                PutLog(btnTotalComp.ToString, txtOptNoEnd.Text, "b-site送信")
                '>>20180111 佐川
                'If inputLotType = INPUTLOTTYPE_DIFF Then
                '    szLotNoSend = szDifLotSend
                'End If
                '<<20180111 佐川
                Dim szCompleteSend As String = FixCharZero(lblCompleteCnt.Text, 8)
                Dim szFrameSend As String = FixCharZero(lblPcbCnt.Text, 8)
                Dim szMultiSend As String = "0"
                Dim szForceSend As String
                If fIsForced Then
                    szForceSend = "1"
                Else
                    szForceSend = "0"
                End If
                Dim szCmdFromSend As String = "0"
                Dim szCmdDefectCntSend As String = FixCharZero("0", 6) 'FixCharZero(lblFailedCnt.Text, 6)
                'FTB画面詰範囲
                If g_CURRENT_EQUIP_TYPE = DEF_ID_FT_BARIN OrElse
                    g_CURRENT_EQUIP_TYPE = DEF_ID_BIST OrElse
                    g_CURRENT_EQUIP_TYPE = DEF_ID_ERASE Then
                    szDifLotSend = FixCharSpace(m_szRange, 12)
                End If
                '週コード
                Dim szWeekCdSend As String = FixCharSpace(m_szWeekCD, 10)
                '検査数
                Dim szCheckCntSend As String = FixCharSpace(m_iCheck.ToString, 8)
                Dim szSelfCheckSend As String = FixCharSpace(m_iSelfCheck.ToString, 8)
                Dim szTrialCheckSend As String = FixCharSpace(m_iTrialCheck.ToString, 8)
                Dim szSideCheckSend As String = FixCharSpace(m_iSideCheck.ToString, 8)
                Dim szChgFrameSend As String = FixCharSpace(m_iChgFrame.ToString, 8)
                Dim szChgBallSend As String = FixCharSpace(m_iChgBall.ToString, 8)
                'b-Site送信用不良数
                Dim lossInf() As InSiteWebService.LossData = {}
                Dim LossQtySum As Integer = 0 'ADD 苗 2018/2/3
                ''DEL MIAO 20200407 BEGIN
                ''>>20180113 佐川
                ''拡散ロットの場合は、不良数をWOKから取得する
                'dgvError.DataSource = m_cLotBadData.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
                ''<<20180113 佐川
                ''ADD 苗 2018/1/18 BEGIN
                'If IsNothing(dgvError) OrElse dgvError.DataSource.rows.count() = 0 Then
                '    dgvError.DataSource = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
                'End If
                'DEL MIAO 20200407 END
                'ADD MIAO 20200407 BEGIN------------------------
                'If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 And doChkFrameID() Then 'Then UPD MIAOJF 2020/07/28
                '    If Not setFrameInfo_OP() Then
                '        HideCommandWaiting()
                '        CommandFailed()
                '        'MsgBox(getMsgStr("MSG10062", "框架信息"))
                '        Exit Sub
                '    End If
                'Else
                '    '拡散ロットの場合は、不良数をWOKから取得する
                '    dgvError.DataSource = m_cLotBadData.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
                '    '<<20180113 佐川
                '    'ADD 苗 2018/1/18 BEGIN
                '    If IsNothing(dgvError) OrElse dgvError.DataSource.rows.count() = 0 Then
                '        dgvError.DataSource = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
                '    End If
                'End If
                ''ADD MIAO 20200407 END--------------------------

                '空芯片（DB)
                'setEmptyChips()

                If Not (IsNothing(dgvError) OrElse dgvError.Rows.Count <= 0) Then
                    szCmdDefectCntSend = FixCharZero(dgvError.Rows.Count, 6)
                    ReDim lossInf(dgvError.Rows.Count - 1)
                    For i = 1 To dgvError.Rows.Count
                        szCmdDefectCntSend &= ":" & FixCharSpace(dgvError(0, i - 1).Value.ToString, 5) & ":" & FixCharSpace(dgvError(2, i - 1).Value.ToString, 6)
                        'b-Site不良数セット
                        lossInf(i - 1) = New InSiteWebService.LossData
                        lossInf(i - 1).LossReason = dgvError(0, i - 1).Value.ToString
                        lossInf(i - 1).LossQty = dgvError(2, i - 1).Value.ToString
                        LossQtySum += CInt(lossInf(i - 1).LossQty) 'ADD 苗 2018/2/3
                    Next
                End If
                'Atlasサーバ送信
                If AutoManualMode <> 0 Then
                    szCmdToSend = String.Format(CMD_NO, szLotNoSend, szKouteiCDSend, szEquipIdSend)
                    clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)
                End If
                '>>20180118 佐川
                '>>20180320 大賀 A10 UDF11が送信されないケースがある
                ' If m_ProcessStatus = ProcessStatus.Processing AndAlso IcTag.szProcsCD.Equals(PROC_CD_TC) Then
                If IcTag.Status = TagProcessStatus.Processing AndAlso IcTag.szProcsCD.Equals(PROC_CD_TC) Then
                    '<<20180320 大賀 A10 UDF11が送信されないケースがある
                    'A10(TC)画面で計上完成時の場合は、ChangeAttributeServiceを実行する
                    sendChangeAttributeService(clientProcCd)
                End If
                '>>20180118 佐川
                ' ----- bSite送信実装 Start
                '>>20171109 兪
                If m_fIsLineEquip Then
                    Dim inputBsite As New InSiteWebService.InMoveStdLine
                    Dim outputBsite As New InSiteWebService.OutMoveStdLine
                    inputBsite.Employee = txtOptNoEnd.Text  '終了作業者
                    inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                    inputBsite.Operation = m_szEndProcCD    '完成工程コード
                    inputBsite.IgnoreWarning = fIsForced    '強制着工
                    inputBsite.LossInf = {lossInf, lossInf} '不良数
                    inputBsite.LossQty2 = {"0", "0"}
                    inputBsite.Qty = {lblCompleteCnt.Text, lblCompleteCnt.Text}  '完成数
                    inputBsite.Qty2 = {lblPcbCnt.Text, lblPcbCnt.Text}
                    If Not String.IsNullOrEmpty(outWeekCode) Then
                        inputBsite.WeeklyCode = outWeekCode '週コード
                    End If
                    outHeader = Nothing
                    outLotInfo = Nothing
                    outputBsite = MoveStdLineService_Execute(inputBsite, clientProcCd)
                    '戻り情報を保持
                    outHeader = outputBsite.Header
                    outLotInfo = outputBsite.LotInf
                Else
                    outHeader = Nothing
                    outLotInfo = Nothing
                    If IsBsiteMulti() Then
                        Dim inputBsite As New InSiteWebService.InMoveStdMultiMachine
                        Dim outputBsite As New InSiteWebService.OutMoveStdMultiMachine
                        inputBsite.Employee = IIf(txtOptNoEnd.Text = "", txtOptNoStt.Text, txtOptNoEnd.Text) '終了作業者
                        inputBsite.Lot = szLotNoSend.Trim               'ロットNo
                        inputBsite.Machine = g_EQUIP_NO                 '装置No
                        inputBsite.IgnoreWarning = False                '強制着工
                        inputBsite.LossInf = lossInf                    '不良数
                        'UPD 苗 2018/1/7 BEGIN
                        If mMultiExecCheck = True Then
                            inputBsite.SuccessQty = 0 '完成数
                            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                            If wf_write_flag = WRITE_WAFER Then
                                inputBsite.Qty2 = IcTag.waferNum
                            Else
                                inputBsite.Qty2 = IcTag.iFrame 'フレーム枚数’ADD 苗　2018/1/17
                            End If
                            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                            Call setCntFromMutliRacks()
                        End If
                        'UPD 苗 2018/1/7 END
                        'inputBsite.LocationCode = mLocationCode         '作業場所
                        outputBsite = MoveStdMultiMachineService_Execute(inputBsite, clientProcCd, mMultiExecCheck)

                        '戻り情報を保持
                        outHeader = outputBsite.Header
                        outLotInfo = outputBsite.LotInf
                    Else
                        If IcTag.szProcsCD.Equals(PROC_CD_TC) Then
                            If getUdf11(szLotNoSend.Trim) = "" Then
                                PutLog(Me.ToString, "UDF11", "NO UDF11" & szLotNoSend.Trim)
                                sendChangeAttributeService(clientProcCd)
                            Else
                                PutLog(Me.ToString, "UDF11", szLotNoSend.Trim)
                            End If
                        End If
                        Dim inputBsite As New InSiteWebService.InMoveStd
                        Dim outputBsite As New InSiteWebService.OutMoveStd
                        inputBsite.Employee = IIf(txtOptNoEnd.Text = "", txtOptNoStt.Text, txtOptNoEnd.Text) '終了作業者
                        inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                        inputBsite.Machine = g_EQUIP_NO         '装置No
                        inputBsite.IgnoreWarning = fIsForced    '強制着工
                        If AProcCD() <> "" Then
                            inputBsite.Qty = IcTag.iInput     '投入数
                        Else
                            inputBsite.LossInf = lossInf            '不良数
                            'inputBsite.Qty = lblCompleteCnt.Text    '完成数
                            'UPD 苗 2018/2/3 BEGIN
                            If LossQtySum = 0 And IcTag.iFinish = 0 Then
                                inputBsite.Qty = IcTag.iInput     '投入数
                            Else
                                inputBsite.Qty = IcTag.iFinish    '完成数
                            End If
                        End If

                        'UPD 苗 2018/2/3 END
                        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                        If wf_write_flag = WRITE_WAFER Then
                            inputBsite.Qty2 = IcTag.waferNum
                        Else
                            inputBsite.Qty2 = IcTag.iFrame 'フレーム枚数’ADD 苗　2018/1/17
                        End If

                        '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                        If Not String.IsNullOrEmpty(outWeekCode) Then
                            inputBsite.WeeklyCode = outWeekCode '週コード
                        End If
                        outputBsite = MoveStdService_Execute(inputBsite, clientProcCd)
                        '戻り情報を保持
                        outHeader = outputBsite.Header
                        outLotInfo = outputBsite.LotInf
                    End If
                End If
                '<<20171109 兪

                ' ----- bSite送信実装 End

                'ADD MIAO 2019/12/9 BEGIN
                '---------MPCへ送信 BEGIN ------------
                If AutoManualMode = 0 Then
                    SendNPtoMPC()
                    'If doSendNPtoMPCinBase() = True Then
                    'Dim rtnIU As String
                    'Dim rtnNP As String

                    'If STS_SUCCESS.Equals(outHeader.Status) Then
                    '    rtnIU = COMMAND_OK
                    '    rtnNP = OK
                    '    NP_IU_RTN = True 'ADD 2020/8/17 miaojf Ver.70
                    '    updateRackInfo()
                    'Else
                    '    NP_IU_RTN = False 'ADD 2020/8/17 miaojf Ver.70
                    '    rtnIU = COMMAND_NG
                    '    rtnNP = NG
                    'End If

                    ''TODO:追加要
                    ''NPコマンドを送信
                    'With IcTag
                    '    strMPCCommand = createStORCompCommandStr(COMMAND_NP, rtnNP, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
                    '                    lblEquipID.Text, "", "", txtOptNoEnd.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
                    'End With
                    'PutLog(Me.ToString, "sendCommand", strMPCCommand)
                    'm_cEquipCommandControl.CommandSend(strMPCCommand)

                    ''IUコマンドを送信
                    ''If LH_FLAG = True Then
                    'sendResponseCommand(COMMAND_IU, rtnIU)
                    ''End If

                    'LN_FLAG = False
                    'LH_FLAG = False
                    'End If
                Else
                    updateRackInfo()
                    'Atlasサーバ送信
                    If STS_SUCCESS.Equals(outHeader.Status) Then
                        If AutoManualMode = 0 Then NP_IU_RTN = True 'ADD 2020/8/17 miaojf Ver.70
                        szCmdToSend = String.Format(CMD_NP, szLotNoSend, szKouteiCDSend, szEquipIdSend, OK)
                    Else
                        If AutoManualMode = 0 Then NP_IU_RTN = False 'ADD 2020/8/17 miaojf Ver.70
                        szCmdToSend = String.Format(CMD_NP, szLotNoSend, szKouteiCDSend, szEquipIdSend, NG)
                    End If
                    clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)

                End If
                'ADD MIAO 2019/12/9 END
                '---------MPCへ送信 END ------------
#Region "DEL"
                '----------- S工程抜取検査 BEGIN -----------
                'Dim objRCHistory As New clsRandCheckHistory
                'Dim dtRCHistory As DataTable
                'Dim KeijyoFlg As Boolean = True
                'Dim A_PROC_SKIP As Boolean = True 'True A工程SKIP
                'dtRCHistory = objRCHistory.selectRandCheckHistory(szLotNoSend.Trim, lblProcessCD.Text, g_EQUIP_NO, "", "")
                'If IsNothing(dtRCHistory) = False AndAlso dtRCHistory.Rows.Count > 0 Then
                '    A_PROC_SKIP = False
                '    If DBNullTOblank(dtRCHistory.Rows(0)("Status")） = OK Then

                '        If MsgBox(getMsgStr("MSG10056"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                '            KeijyoFlg = True
                '        Else
                '            KeijyoFlg = False
                '        End If
                '    ElseIf DBNullTOblank(dtRCHistory.Rows(0)("Status")) = NG Then
                '        KeijyoFlg = False
                '        MsgBox(getMsgStr("MSG10057"))
                '    Else
                '        KeijyoFlg = False

                '        updateRCRackID()
                '    End If
                '    'TODO:削除20200404
                '    'Else
                '    '    A_PROC_SKIP = True
                'End If
                '----------- S工程抜取検査 END   ----------- 

                ''If A_PROC_SKIP = False And AProcStartCompleteFLG() = True Then '工程スキップ
                'If AProcStartCompleteFLG() = True Then 'A工程は着完工やるか判断(S41,S51:True,S42:False)

                '    '----------- A工程着工 BEGIN  ----------- 
                '    Dim inputBsite As New InSiteWebService.InMoveIn
                '    Dim outputBsite As New InSiteWebService.OutMoveIn

                '    clientProcCd = m_cEquipMat.GetBsiteClientString(AProcCD)

                '    inputBsite.Employee = txtOptNoEnd.Text  '開始作業者
                '    inputBsite.Lot = szLotNoSend.Trim       'ロットNo
                '    inputBsite.Machine = g_EQUIP_NO 'A_PROC_EQUIP         '装置No
                '    inputBsite.IgnoreLimitTime = fIsForced   '強制着工
                '    inputBsite.MoveInForWaferLot = moveInWaferLot   '拡散ロット着工
                '    If Not String.IsNullOrEmpty(outWeekCode) Then
                '        inputBsite.WeeklyCode = outWeekCode '週コード
                '    End If

                '    outputBsite = MoveInService_Execute(inputBsite, clientProcCd)
                '    '戻り情報を保持
                '    outHeader = outputBsite.Header
                '    outLotInfo = outputBsite.LotInf
                '    'A工程の着工履歴作成
                '    m_cEquipMat.saveAProcResultForRC(lblProcessCD.Text, AProcCD, "1", szLotNoSend.Trim)
                '    '----------- A工程着工  END   ----------- 

                '    '    '----------- A工程完工 BEGIN  ----------- 
                '    If KeijyoFlg = True OrElse A_PROC_SKIP = True Then
                '        Dim dtFrameNG As DataTable = Nothing
                '        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then

                '            dtFrameNG = getFrameNG(AProcCD)

                '        Else
                '            '拡散ロットの場合は、不良数をWOKから取得する
                '            dtFrameNG = m_cLotBadData.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, AProcCD)

                '            '<<20180113 佐川
                '            'ADD 苗 2018/1/18 BEGIN
                '            If IsNothing(dtFrameNG) OrElse dtFrameNG.Rows.Count() = 0 Then
                '                dtFrameNG = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, AProcCD)
                '            End If
                '        End If

                '        'ADD 苗 2018/1/18 END
                '        If Not (IsNothing(dtFrameNG) OrElse dtFrameNG.Rows.Count <= 0) Then
                '            'szCmdDefectCntSend = FixCharZero(dgvError.Rows.Count, 6)
                '            ReDim lossInf(dtFrameNG.Rows.Count - 1)
                '            For i = 1 To dtFrameNG.Rows.Count
                '                'szCmdDefectCntSend &= ":" & FixCharSpace(dgvError(0, i - 1).Value.ToString, 5) & ":" & FixCharSpace(dgvError(2, i - 1).Value.ToString, 6)
                '                'b-Site不良数セット
                '                lossInf(i - 1) = New InSiteWebService.LossData
                '                lossInf(i - 1).LossReason = dtFrameNG(0).ToString
                '                lossInf(i - 1).LossQty = dtFrameNG(2).ToString
                '                LossQtySum += CInt(lossInf(i - 1).LossQty) 'ADD 苗 2018/2/3
                '            Next
                '        End If

                '        Dim frameinfo = getFrameInfo()
                '        If IsNothing(frameinfo) Then
                '            MsgBox（"框架信息读取失败。")
                '            Exit Sub
                '        Else

                '            Dim inputBsiteStd As New InSiteWebService.InMoveStd
                '            Dim outputBsiteStd As New InSiteWebService.OutMoveStd
                '            inputBsiteStd.Employee = txtOptNoEnd.Text  '終了作業者
                '            inputBsiteStd.Lot = szLotNoSend.Trim       'ロットNo
                '            inputBsiteStd.Machine = g_EQUIP_NO 'A_PROC_EQUIP         '装置No
                '            inputBsiteStd.IgnoreWarning = fIsForced    '強制着工
                '            inputBsiteStd.LossInf = lossInf            '不良数 
                '            'inputBsite.Qty = lblCompleteCnt.Text    '完成数
                '            'UPD 苗 2018/2/3 BEGIN
                '            If LossQtySum = 0 Then 'And IcTag.iFinish = 0 Then
                '                inputBsiteStd.Qty = Val(frameinfo("totalPkgCnt").ToString())    '投入数
                '            Else
                '                inputBsiteStd.Qty = Val(frameinfo("totalOkCnt").ToString())    '完成数
                '            End If
                '            'UPD 苗 2018/2/3 END
                '            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力

                '            inputBsiteStd.Qty2 = Val(frameinfo("frameCnt").ToString()) 'フレーム枚数’ADD 苗　2018/1/17

                '            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                '            If Not String.IsNullOrEmpty(outWeekCode) Then
                '                inputBsiteStd.WeeklyCode = outWeekCode '週コード
                '            End If

                '            outputBsiteStd = MoveStdService_Execute(inputBsiteStd, clientProcCd)
                '            '戻り情報を保持
                '            outHeader = outputBsiteStd.Header
                '            outLotInfo = outputBsiteStd.LotInf
                '            'A工程の完工履歴作成
                '            m_cEquipMat.saveAProcResultForRC(lblProcessCD.Text, AProcCD, "3", szLotNoSend.Trim, frameinfo)
                '        End If
                '    End If
                'End If
                '----------- A工程完工  END   ----------- 
                'End If

            'End If
#End Region

            Case CommandType.JC
                PutLog(btnCancel.ToString, txtOptNoStt.Text, "b-site送信")
                '>>20180111 佐川
                'If inputLotType = INPUTLOTTYPE_DIFF Then
                '    szLotNoSend = szDifLotSend
                'End If
                '<<20180111 佐川
                ' ----- bSite送信実装 Start
                Dim inputBsite As New InSiteWebService.InMoveInCancel
                Dim outputBsite As New InSiteWebService.OutMoveInCancel
                inputBsite.Employee = txtOptNoStt.Text
                inputBsite.Lot = szLotNoSend.Trim
                inputBsite.Machine = g_EQUIP_NO         '装置No
                outHeader = Nothing
                outputBsite = MoveInCancelService_Execute(inputBsite, clientProcCd)
                '戻り情報を保持
                outHeader = outputBsite.Header
                '通信フロー（キャンセル対応）BEGIN
                If AutoManualMode = 0 Then
                    Dim rtn As String = OK

                    If outHeader.Status <> STS_SUCCESS Then
                        rtn = NG
                    End If
                    'TODO：追加要
                    'NDコマンド
                    With tagData
                        strMPCCommand = createStORCompCommandStr(COMMAND_ND, rtn, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
                                           lblEquipID.Text, "", "", txtOptNoStt.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
                    End With
                    PutLog(Me.ToString, "sendCommand", strMPCCommand)
                    m_cEquipCommandControl.CommandSend(strMPCCommand)

                End If
            '通信フロー（キャンセル対応）END
                ' ----- bSite送信実装 End
                'szCmdToSend = String.Format(CMD_JC,
                '                            szLotNoSend, szKouteiCDSend, szFactorySend, szOperatorStartSend,
                '                            szTypeSend, szEquipIdSend, szEquipNoSend)
            Case CommandType.JM
                PutLog(Me.ToString, txtOptNoStt.Text, String.Format("材料「{0}」セットアップ、b-site送信", m_szMatType))
                Dim szLotStatusSend As String
                If m_ProcessStatus = ProcessStatus.Processing Then
                    szLotStatusSend = "1"
                Else
                    szLotStatusSend = "0"
                End If
                Dim szMatIdSend As String = FixCharSpace(m_szMatID, 10)
                Dim szMatCataSend As String = FixCharSpace(m_szMatCata, 20)
                Dim szMatTypeSend As String = FixCharSpace(m_szMatType, 20)
                Dim szMatLotSend As String = FixCharSpace(m_szMatLot, 20)
                Dim szMakerLotSend As String = FixCharSpace(m_szMakerLot, 20)
                Dim szWarnLtSend As String = FixCharSpace(m_szMatLT, 20)
                Dim szErrorLtSend As String = FixCharSpace(m_szMatLT, 20)
                ' ----- 仮 bSite送信実装 Start
                'Dim inputBsite As New InSiteWebService.InMachineSetup
                'Dim outputBsite As New InSiteWebService.OutMachineSetup
                'inputBsite.Employee = txtOptNoStt.Text
                'inputBsite.Machine = lblEquipID.Text
                'Dim matInfo = New InSiteWebService.Machine_Material
                'matInfo.Category = m_szMatCata
                'matInfo.Type = m_szMatType
                'matInfo.Lot = m_szMatLot
                'matInfo.OriginalLot = m_szMakerLot
                'matInfo.UsageLimitCountW = m_szMatLT
                'matInfo.UsageLimitCountE = m_szMatLT   
                'inputBsite.MaterialInf(0) = matInfo

                'outHeader = Nothing
                'outputBsite = MachineSetupService_Execute(inputBsite)
                '戻り情報を保持
                'outHeader = outputBsite.Header
                outHeader = New InSiteWebService.OutHeader
                outHeader.Status = STS_SUCCESS
                ' ----- 仮 bSite送信実装 End

                'szCmdToSend = String.Format(CMD_JM,
                '                            szLotNoSend, szKouteiCDSend, szFactorySend, szOperatorStartSend,
                '                            szLotStatusSend, szTypeSend, szEquipIdSend, szEquipNoSend,
                '                            szMatIdSend, szMatCataSend, szMatTypeSend, szMatLotSend,
                '                            szMakerLotSend, szWarnLtSend, szErrorLtSend)
            Case Else
                szCmdToSend = String.Empty
        End Select

        'コマンドの発信
        'clsDbServerCommand.SendLotCommand(szCmdToSend, m_szIP)

        '<<20170717

        'b-site返事タイマーを起動
        m_iTimerCnt = 0
        '>>20180111 兪
        intTimer_Tick(intTimer, New EventArgs)
        '<<20180111 兪

    End Sub
    Overridable Function doSendNPtoMPCinBase() As Boolean
        Return True
    End Function
    Overridable Sub SendNPtoMPC()
        Dim rtnIU As String
        Dim rtnNP As String
        Dim strMPCCommand1 As String
        If STS_SUCCESS.Equals(outHeader.Status) Then
            rtnIU = COMMAND_OK
            rtnNP = OK
            NP_IU_RTN = True 'ADD 2020/8/17 miaojf Ver.70
            updateRackInfo()
        Else
            NP_IU_RTN = False 'ADD 2020/8/17 miaojf Ver.70
            rtnIU = COMMAND_NG
            rtnNP = NG
        End If

        'TODO:追加要
        'NPコマンドを送信
        With IcTag
            strMPCCommand1 = createStORCompCommandStr(COMMAND_NP, rtnNP, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
                            lblEquipID.Text, "", "", txtOptNoEnd.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
        End With
        PutLog(Me.ToString, "baseSC", strMPCCommand1)
        m_cEquipCommandControl.CommandSend(strMPCCommand1)

        'IUコマンドを送信
        'If LH_FLAG = True Then
        sendResponseCommand(COMMAND_IU, rtnIU)
        'End If

        LN_FLAG = False
        LH_FLAG = False
    End Sub
    Overridable Sub setEmptyChips()

    End Sub
    Overridable Sub updateRackInfo()

    End Sub
    Overridable Function getInRackNo() As String
        Return ""
    End Function

    'Protected Overridable Function setFrameInfo_OP() As Boolean
    '    PutLog(Me.ToString, "FRAME ID", " in setFrameInfo_OP")
    '    Dim frameinfo = getFrameInfo()
    '    If IsNothing(frameinfo) Then
    '        PutLog(Me.ToString, "FRAME ID", "error3=  IsNothing(frameinfo)")
    '        HideCommandWaiting()
    '        CommandFailed()
    '        Return False
    '    End If

    '    If Not IsNothing(lblEmptyChipsCnt) Then
    '        lblEmptyChipsCnt.Text = frameinfo("vacantPcbCnt").ToString '空チップ数 
    '    End If
    '    lblPcbCnt.Text = Val(frameinfo("frameCnt").ToString())
    '    lblCrossCnt.Text = Val(frameinfo("totalCrossCnt").ToString())
    '    lblCrossPcbCnt.Text = Val(frameinfo("crossPcbCnt").ToString())
    '    RemoveHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged
    '    lblFailedCnt.Text = Val(frameinfo("totalNgCnt").ToString())
    '    If dgvError.Rows.Count > 0 Then
    '        PutLog(Me.ToString, "FRAME ID", "dgvError.Rows.Count > 0")
    '        Dim errsum As Integer
    '        For i As Integer = 0 To dgvError.DataSource.Rows.Count - 1
    '            Try
    '                errsum = errsum + CInt(dgvError.DataSource.Rows(i)(3))
    '            Catch ex As Exception
    '                errsum = 0
    '            End Try
    '        Next
    '        lblFailedCnt.Text = errsum.ToString
    '        PutLog(Me.ToString, "FRAME ID", "lblFailedCnt.Text " & lblFailedCnt.Text)

    '    End If

    '    AddHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged

    '    lblCompleteCnt.Text = Val(frameinfo("totalOkCnt").ToString())
    '    If isRackNoFlow() = True Then
    '        lblCompleteCnt.Text = Val(frameinfo("totalOkCnt").ToString) + Val(frameinfo("vacantPcbCnt").ToString) '良品数
    '    End If
    '    Me.Refresh()
    '    Return True
    'End Function
    ''' <summary>
    ''' フレーム情報を取得して返却します。
    ''' </summary>
    ''' <returns></returns>
    Protected Function getFrameInfo(Optional ByVal inputProcCD As String = "") As Hashtable
        Dim ht As Hashtable = New Hashtable
        Dim dtFrameData As New DataTable
        Dim procCD As String = ""
        If inputProcCD = "" Then
            If AProcCD() <> "" Then
                procCD = AProcCD()
            Else
                procCD = lblProcessCD.Text
            End If
        Else
            procCD = inputProcCD
        End If
        PutLog(Me.ToString, "FRAME ID", "procCD=" & procCD & "IcTag.szLotNo=" & IcTag.szLotNo & "lblEquipID.Text=" & lblEquipID.Text)

        dtFrameData = m_cLotDefect.GetFrameInfo(procCD, IcTag.szLotNo, lblEquipID.Text)

        If dtFrameData.Rows.Count <= 0 Then
            PutLog(Me.ToString, "FRAME ID", "error= dtFrameData.Rows.Count = 0")

            'MsgBox(getMsgStr("MSG00181", IcTag.szLotNo))
            Return Nothing
        ElseIf dtFrameData.Rows.Count = 1 Then
            With dtFrameData.Rows(0)
                Dim a As String = .Item(0) & "|" & .Item(1) & .Item(2) & .Item(3) &
                    .Item(4) & .Item(5) & .Item(6) & .Item(7)
                PutLog(Me.ToString, "FRAME ID", a)
            End With

            '1レコード取れるが空の場合がある
            If IsDBNull(dtFrameData.Rows(0)("totalPkgCnt")) Then
                PutLog(Me.ToString, "FRAME ID", "error=  IsDBNull(dtFrameData.Rows(0)(totalPkgCnt))")
                'MsgBox(getMsgStr("MSG00181", IcTag.szLotNo))
                Return Nothing
            End If
        End If

        'by xulei 2018/11/13 不良情報を追加
        Dim strMapData As String = dtFrameData.Rows(0).Item("map_data")
        Dim CategoryCode As New List(Of String)
        For i = 0 To strMapData.Length - 1
            If Not strMapData.Substring(i, 1).Equals("1") And Not CategoryCode.Contains(strMapData.Substring(i, 1)) Then
                CategoryCode.Add(strMapData.Substring(i, 1))
                PutLog(Me.ToString, "FRAME ID", "CategoryCode：" & strMapData.Substring(i, 1))

            End If
        Next

        Dim dtMapData As New DataTable

        If CategoryCode.Count > 0 Then
            Dim strCategoryCode() As String = CategoryCode.ToArray

            dtMapData = m_cLotDefect.GetErrorInfo(g_CURRENT_EQUIP_TYPE.ToString, strCategoryCode)

            dtMapData.Columns.Add("QTY")
            Dim intError As Integer
            For i = 0 To dtMapData.Rows.Count - 1
                intError = 0
                For j = 0 To strMapData.Length - 1
                    If dtMapData.Rows(i).Item("category_code").ToString.Equals((System.Text.Encoding.Default.GetBytes(strMapData.Substring(j, 1))(0)).ToString) Then
                        intError += 1
                    End If
                Next j
                dtMapData.Rows(i).Item("QTY") = intError
            Next i

            dgvError.DataSource = dtMapData
            dgvError.Columns(1).HeaderText = "Code"
            dgvError.Columns(2).HeaderText = "不良内容"
            dgvError.Columns(3).HeaderText = "数量"
            dgvError.Columns.Remove("category_code")
            dgvError.Visible = True
        End If
        'by xulei 2018/11/13 不良情報を追加

        If dtFrameData.Rows.Count <= 0 Then
            'MsgBox(getMsgStr("MSG00181", IcTag.szLotNo))
            PutLog(Me.ToString, "FRAME ID", "error2= dtFrameData.Rows.Count = 0")
            Return Nothing
        ElseIf dtFrameData.Rows.Count = 1 Then
            '1レコード取れるが空の場合がある
            If IsDBNull(dtFrameData.Rows(0)("totalPkgCnt")) Then
                PutLog(Me.ToString, "FRAME ID", "error2=  IsDBNull(dtFrameData.Rows(0)(totalPkgCnt))")
                'MsgBox(getMsgStr("MSG00181", IcTag.szLotNo))
                Return Nothing
            End If
        End If

        'by xulei 2019/4/2 良品のないフレームからはデータを取得しないため、不良の総件数は不良詳細情報から取得
        Dim intNg As Int32 = 0
        For i = 0 To dtMapData.Rows.Count - 1
            intNg += Val(dtMapData.Rows(i).Item("QTY").ToString)
        Next
        'by xulei 2019/4/2

        For Each dr In dtFrameData.Rows
            '総数
            ht.Add("totalPkgCnt", dr("totalPkgCnt"))
            '良品数
            ht.Add("totalOkCnt", dr("totalOkCnt"))
            '不良品数
            'ht.Add("totalNgCnt", dr("totalNgCnt"))
            ht.Add("totalNgCnt", intNg)
            '空チップ数
            ht.Add("totalVacantChipCnt", dr("totalEmptyCnt"))
            '空チップ枚数
            ht.Add("vacantPcbCnt", dr("totalEmptyCnt"))
            'Ｘ印数
            ht.Add("totalCrossCnt", dr("totalCrossCnt"))
            'Ｘ印枚数
            ht.Add("crossPcbCnt", dr("crossPcbCnt"))
            'フレーム数
            ht.Add("frameCnt", dr("frameCnt"))

        Next
        Return ht
    End Function

    Private Function getFrameNG(procCD As String) As DataTable

        Dim ht As Hashtable = New Hashtable
        Dim dtFrameData As New DataTable


        Dim strMapData As String = m_cLotDefect.getFrameMapData(procCD, IcTag.szLotNo, lblEquipID.Text)
        Dim CategoryCode As New List(Of String)
        For i = 0 To strMapData.Length - 1
            If Not strMapData.Substring(i, 1).Equals("1") And Not CategoryCode.Contains(strMapData.Substring(i, 1)) Then
                CategoryCode.Add(strMapData.Substring(i, 1))
            End If
        Next

        Dim dtMapData As New DataTable

        If CategoryCode.Count > 0 Then
            Dim strCategoryCode() As String = CategoryCode.ToArray

            dtMapData = m_cLotDefect.GetErrorInfo(g_CURRENT_EQUIP_TYPE.ToString, strCategoryCode)

            dtMapData.Columns.Add("QTY")
            Dim intError As Integer
            For i = 0 To dtMapData.Rows.Count - 1
                intError = 0
                For j = 0 To strMapData.Length - 1
                    If dtMapData.Rows(i).Item("category_code").ToString.Equals((System.Text.Encoding.Default.GetBytes(strMapData.Substring(j, 1))(0)).ToString) Then
                        intError += 1
                    End If
                Next j
                dtMapData.Rows(i).Item("QTY") = intError
            Next i

        End If

        Return dtMapData
    End Function
    'Bsite待ちのメッセージを表示
    Protected Sub ShowBsiteWaiting()
        Me.Cursor = Cursors.WaitCursor
        lblWait.Top = Int((Me.Height - lblWait.Height) / 2)
        lblWait.Left = Int((Me.Width - lblWait.Width) / 2)
        lblWait.BringToFront()
        lblWait.Visible = True
        Me.Enabled = False

    End Sub

    '不良カタゴリを取得
    Overridable Sub GetDefectCata()
        If m_IsHolding = OnHoldStatus.Solved Then
            lblFailedCnt.Text = "0"
            dtError.Clear()
            dgvError.DataSource = dtError
            Exit Sub
        End If
        '>>20171021 兪
        'If g_CURRENT_EQUIP_TYPE = DEF_ID_DB OrElse
        '   g_CURRENT_EQUIP_TYPE = DEF_ID_DBAFC OrElse
        '   g_CURRENT_EQUIP_TYPE = DEF_ID_WB OrElse
        '   g_CURRENT_EQUIP_TYPE = DEF_ID_MOLD_AFC OrElse
        '   g_CURRENT_EQUIP_TYPE = DEF_ID_PLATE OrElse
        '   g_CURRENT_EQUIP_TYPE = DEF_ID_PLATING_BAKE OrElse
        '   lblProcessCD.Tag = PROC_CD_PLASMA_WB Then
        '    '組立工程の不良数を表示しない
        '    dtError = m_cLotDefect.GetAsmDefectData(lotNo, g_CURRENT_EQUIP_ID)
        '    dgvError.DataSource = Nothing
        '    dgvError.Visible = False
        '    Exit Sub
        'ElseIf g_CURRENT_EQUIP_TYPE = DEF_ID_INSP Then
        '    dtError = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IcTag.szProcsCD)
        'Else
        '>>20180113 安部
        If m_szPreProcLotType = "0" Then
            dtError = m_cLotDefect.GetDefectData(txtDiffLot.Text, g_CURRENT_EQUIP_ID, IIf(AProcCD() = "", IcTag.szProcsCD, AProcCD))
        Else
            dtError = m_cLotDefect.GetDefectData(lotNo, g_CURRENT_EQUIP_ID, IIf(AProcCD() = "", IcTag.szProcsCD, AProcCD))
        End If
        '<<20180113 安部
        'End If
        '<<20171021 兪
        If IsNothing(dtError) OrElse dtError.Columns.Count <= 0 OrElse dtError.Rows.Count <= 0 Then
            lblFailedCnt.Text = "0"
            dgvError.Visible = False
            Exit Sub
        End If
        dgvError.DataSource = dtError
        dgvError.Visible = True
    End Sub

    Overridable Function SaveCompleteInfo(Optional ByVal status As ProcessStatus = ProcessStatus.ManufComplete) As Integer
        Dim dte As DateTime = DateTime.Now
        'ヘッダ情報を更新する
        UpdateHeader(status, dte.ToString(DATE_TIME_FORMAT_DB))
        '完成情報をDBに保存
        Dim cnt As Integer = m_cEquipMat.SaveCompleteInfo(g_EQUIP_NO, lotNo,'UPD 苗 2018/1/19 装置No.の対応
                                           dte, txtOptNoEnd.Text,
                                            m_szTable, m_dtHeader,
                                     m_szCheck,
                                     m_szSelfCheck,
                                     m_szTrialCheck,
                                     m_szSideCheck,
                                     m_szChgFrame,
                                     m_szChgBall,
                                     lblCrossCnt.Text)
        'If cnt > 0 Then
        '完成日時の表示
        lblEndTime.Text = dte.ToString(DATE_TIME_FORMAT)
        'End If
        Return cnt
    End Function

    Overridable Function SaveTotalInfo() As Integer
        Return 0
    End Function

    ''' <summary>
    ''' 工程フローの表示
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ShowProcFlow()
        'dgvFlow.DataSource = Nothing
        dtFlow = m_cEquipMat.GetKoteiData(IIf(lblLotNo.Text = "", txtLotNo.Text, lblLotNo.Text), m_szProc, lotNo)
        If Not dtFlow.Rows.Count > 0 Then
            dtFlow.Rows.Clear()
        End If
        dgvFlow.DataSource = dtFlow
        dgvFlow.ClearSelection()
        dgvFlow.Columns("PROC").HeaderText = "工程名"
        dgvFlow.Columns("PROC").Width = 150
        dgvFlow.Columns("QTY").HeaderText = "完成数"
        dgvFlow.Columns("QTY").Width = 65
    End Sub

    Protected Sub ClearSetupData()
        m_szMatID = String.Empty
        m_szMatType = String.Empty
        m_szMatLot = String.Empty
        m_szMakerLot = String.Empty
        m_szMatLT = String.Empty
        m_szMatLT = String.Empty
    End Sub

    Overridable Function SaveQty() As Integer
        Return m_cEquipMat.SaveQty(lblLotNo.Text, g_EQUIP_NO, m_szTable,'UPD 苗 2018/1/19 装置No.の対応
                                                     m_szCheck, m_szSelfCheck, m_szTrialCheck, m_szSideCheck, m_szChgFrame, m_szChgBall,
                                                     lblCrossCnt.Text)
    End Function

    Public Function PutDbLog(ByVal logRecord As Log) As Integer
        Return m_cLog.PutDbLog(logRecord)
    End Function

#End Region

#Region "治工具、材料照合"
    '照合完成イベント
    Public Event CollectionDone As EventHandler
    Protected Overridable Sub OnCollectionDone(ByVal e As EventArgs)
        If m_ProcessStatus = ProcessStatus.Processing Then
            Exit Sub
        End If
        If chkCrossFrame() Then
            RaiseEvent CollectionDone(Me, e)
        End If

    End Sub

    '一括照合
    Overridable Sub MatCollAll()
        CheckCollScore()
    End Sub

    '単体照合
    Protected Function MatCollSingle(ByVal lblSys As Label, ByVal txtData As TextBox, ByVal lblData As Label) As String
        If Not String.IsNullOrEmpty(lblSys.Text.Trim) AndAlso txtData.TextLength <= 0 Then
            MatCollSingle = String.Format("「{0}」は空白です。" & vbCrLf, lblData.Tag)
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            Exit Function
        End If
        Dim idx As Integer
        If IsNumeric(txtData.Tag) Then
            idx = CInt(txtData.Tag) - 1
        Else
            idx = CInt(txtData.Tag.ToString.Substring(1)) - 1
        End If
        If Not MatColl(lblSys.Text.Trim, txtData.Text.Trim, idx) Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            MatCollSingle = String.Format("「{0}」は製造条件と不一致です。" & vbCrLf, lblData.Tag)
            Exit Function
        End If
        Dim iBtn As Integer = CInt(txtData.Tag) - 1
        Dim btnBarCode() As Control = txtData.Parent.Controls.Find("btnBarCode" & iBtn.ToString.Replace("0", ""), False)
        If btnBarCode.Length > 0 Then
            txtData.BackColor = BARCODE_INIT_COLOR
            lblData.BackColor = BARCODE_INIT_COLOR
        Else
            txtData.BackColor = NORMAL_INIT_COLOR
            lblData.BackColor = NORMAL_INIT_COLOR
        End If
        MatCollSingle = String.Empty
    End Function


    'バーコード用単体照合
    Protected Function MatCollBarcode(ByVal sender As Object, ByVal lblSys As String, ByVal txtData As TextBox, ByVal lblData As Label) As Boolean

        Dim CheckFlag As Boolean
        Dim lblItem As Label = lblData.Parent.Controls.Find(String.Format("lbl{0}00", lblData.Name.ToString.Substring(3, 2)), False)(0)
        Dim txtTag As String = ""

        Dim idx As Integer
        idx = CInt(lblData.Name.Substring(3, 2)) - 1

        ' 空白チェック
        CheckFlag = checkBlank(txtData.Text, lblItem.Text)
        If Not CheckFlag Then
            checkColor(sender, CheckFlag, lblData.Name)
            m_iScore(idx) = 0
            Return False
        End If

        ' 型チェック
        If Not String.IsNullOrEmpty(lblData.Tag) Then
            txtTag = lblData.Tag
        End If
        CheckFlag = checkType(txtData.Text, lblItem.Text, txtTag)
        If Not CheckFlag Then
            checkColor(sender, CheckFlag, lblData.Name)
            m_iScore(idx) = 0
            Return False
        End If

        If Not lblSys.Equals("-") Then
            ' 条件一致チェック
            CheckFlag = checkMatch(lblSys, txtData.Text, lblItem.Text, lblData.Name)
            checkColor(sender, CheckFlag, lblData.Name)
            If Not CheckFlag Then
                m_iScore(idx) = 0
                Return False
            Else
                m_iScore(idx) = 1
            End If
        Else
            m_iScore(idx) = 1
        End If
        Return True
    End Function

    'テンキー用単体照合
    Protected Function MatCollTenkey(ByVal sender As Object) As Boolean

        Dim CheckFlag As Boolean
        Dim lblItem As Label
        Dim lblData As Label = CType(sender, Label)
        Dim lblSys As Label
        Dim chrSys As String                            ' 製造条件の項目名
        Dim idx As Integer

        'ヘッダー有無
        If lblData.Name.ToString.Substring(5, 2).Equals("01") Then
            chrSys = ""
        Else
            lblSys = lblData.Parent.Controls.Find(String.Format("lbl{0}02", lblData.Name.ToString.Substring(3, 2)), False)(0)
            chrSys = lblSys.Text
        End If

        lblItem = lblData.Parent.Controls.Find(String.Format("lbl{0}00", lblData.Name.ToString.Substring(3, 2)), False)(0)
        idx = CInt(lblData.Name.Substring(3, 2)) - 1

        ' 空白チェック
        CheckFlag = checkBlank(lblData.Text, lblItem.Text)
        If Not CheckFlag Then
            checkColor(sender, CheckFlag, lblData.Name)
            m_iScore(idx) = 0
            Return False
        End If

        '前工程完成数チェック
        If IcTag.Status = TagProcessStatus.Ready And lblItem.Tag.Equals(GC_CHECK_COUNT) Then
            If checkCntCheck() Then
                Return True
            Else
                Return False
            End If
        End If

        ' 型チェック
        CheckFlag = checkType(lblData.Text, lblItem.Text, lblData.Tag)
        If Not CheckFlag Then
            checkColor(sender, CheckFlag, lblData.Name)
            m_iScore(idx) = 0
            Return False
        End If

        ' 着工待ち以外のウェハケースNo
        If IcTag.Status <> TagProcessStatus.Ready And lblItem.Tag.Equals(GC_WAFER_CASE_NO) Then
            ' 条件一致チェック不要
            checkColor(sender, True, lblData.Name)
            Return True
        End If

        If tenkeyChkMatchFlg Then
            ' 条件一致チェック
            CheckFlag = checkMatch(chrSys, lblData.Text, lblItem.Text, lblData.Name)
            checkColor(sender, CheckFlag, lblData.Name)
            If Not CheckFlag Then
                m_iScore(idx) = 0
                Return False
            Else
                m_iScore(idx) = 1
                CheckCollScore()
            End If
        End If

        Return True
    End Function

    Protected Function MatCollSingle(ByVal lblSys As Label, ByVal bcc As BarCodeCell, ByVal lblTitl As Label) As String
        If Not String.IsNullOrEmpty(lblSys.Text.Trim) AndAlso bcc.Text.Length <= 0 Then
            MatCollSingle = getMsgStr("MSG00020", lblTitl.Text)
            bcc.SetCellError()
            Exit Function
        End If
        Dim idx As Integer = CInt(bcc.Tag)
        If Not MatColl(lblSys.Text.Trim, bcc.Text.Trim, idx) Then
            bcc.SetCellError()
            MatCollSingle = getMsgStr("MSG00021", lblTitl.Text)
            Exit Function
        End If
        bcc.RestoreCellError()
        MatCollSingle = String.Empty
    End Function

    'チェック処理
    ' 空白チェック
    Protected Function checkBlank(ByVal lblData As String, ByVal lblItem As String) As Boolean

        If lblData.Length <= 0 Then
            MsgBox(getMsgStr("MSG00020", lblItem))
            Return False
        End If
        Return True
    End Function

    ' 型チェック
    Protected Function checkType(ByVal lblData As String, ByVal lblItem As String, ByVal txtTag As String) As Boolean

        If txtTag.IndexOf(KEYPAD_MW) >= 0 Then
            Dim firstChara = lblData.Substring(0, 1)
            If Not (firstChara.Equals(btnM.Text) Or firstChara.Equals(btnW.Text)) Then
                MsgBox(getMsgStr("MSG00065", lblItem))
                Return False
            End If
        ElseIf txtTag.IndexOf(KEYPAD_SLASH) >= 0 Then
            Dim strSlash = btnSlash.Text

            '形式チェック（数値/数値）
            Dim r As New System.Text.RegularExpressions.Regex("^[0-9]+" & strSlash & "[0-9]+$")
            If Not r.IsMatch(lblData) Then
                MsgBox(getMsgStr("MSG00098", lblItem))
                Return False
            End If

            '整合性チェック
            Dim failedCnt = CInt(lblData.Substring(0, lblData.IndexOf(strSlash)))
            Dim checkCnt = CInt(lblData.Substring(lblData.IndexOf(strSlash) + strSlash.Length))
            If failedCnt > checkCnt Then
                MsgBox(getMsgStr("MSG00099", lblItem))
                Return False
            End If
        End If
        Return True
    End Function

    ' 条件一致チェック
    Protected Function checkMatch(ByVal lblSys As String, ByVal lblData As String, ByVal lblItem As String, ByVal lblName As String) As Boolean

        ' 製造条件なしの場合は、チェック不要
        If lblName.Substring(5, 2).Equals("03") And Not lblSys.Equals("-") Then
            If Not lblSys.Equals(lblData) Then
                MsgBox(getMsgStr("MSG00021", lblItem))
                Return False
            End If
        End If
        ' 前工程ウェハ枚数入力チェック
        If lblName.Substring(5, 2).Equals("01") Then
            Dim dataNumber As Double = Double.Parse(lblData)
            If dataNumber < 1 Then
                MsgBox(getMsgStr("MSG00048", lblItem))
                Return False
            End If
        End If
        ' 前工程データ一致チェック
        If lblName.Substring(5, 2).Equals("02") Then
            If Not lblSys.Equals(lblData) Then
                MsgBox(getMsgStr("MSG00052", lblItem))
                Return False
            End If
        End If

        Return True
    End Function

    '色判定
    Protected Sub checkColor(ByVal sender As Object, ByVal result As Boolean, ByVal lblName As String)
        If TypeOf sender Is TextBox Then
            Dim txtData As TextBox = CType(sender, TextBox)
            Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}{1}", txtData.Tag.ToString, lblName.Substring(5, 2)), False)(0)
            If result Then
                lblData.BackColor = ENTERED_INIT_COLOR
                txtData.BackColor = ENTERED_INIT_COLOR
            Else
                lblData.BackColor = ERROR_INIT_COLOR
                txtData.BackColor = ERROR_INIT_COLOR
            End If

        Else
            Dim lblData As Label = CType(sender, Label)
            If result Then
                lblData.BackColor = ENTERED_INIT_COLOR
            Else
                lblData.BackColor = ERROR_INIT_COLOR
            End If
        End If


    End Sub

    'リミットタイム照合
    Protected Function MatCollLimitTime(ByVal lblCond As Label, ByVal lblLT As Label) As String
        Dim idx As Integer = CInt(lblLT.Tag)
        '条件がなければ照合成功にする
        If String.IsNullOrEmpty(lblCond.Text) Then
            lblLT.BackColor = NORMAL_INIT_COLOR
            m_iScore(idx) = 1
            CheckCollScore()
            MatCollLimitTime = String.Empty
            Exit Function
        End If

        Dim dteLimitTime As DateTime
        Try
            dteLimitTime = CDate(lblLT.Text)
        Catch ex As Exception
            dteLimitTime = CDate("2001/01/01 00:00")
        End Try

        If dteLimitTime > DateTime.Now Then
            lblLT.BackColor = NORMAL_INIT_COLOR
            m_iScore(idx) = 1
            CheckCollScore()
            MatCollLimitTime = String.Empty
        Else
            lblLT.BackColor = ERROR_INIT_COLOR
            'm_iScore(idx) = 0
            'm_fColl = False
            'MatCollLimitTime = "有効期限が切れました。" & vbCrLf

            '無条件照合成功
            'Dim idx As Integer = cint(lblLT.Tag)
            'lblLT.BackColor = NORMAL_INIT_COLOR
            m_iScore(idx) = 1
            CheckCollScore()
            MatCollLimitTime = String.Empty
        End If
    End Function

    '照合成功処理
    Protected Sub frmStartCompleteDB_CollectionDone(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.CollectionDone
        m_fColl = True

        If txtOptNoStt.TextLength <= 0 Then
            Exit Sub
        End If

        '着工中であれば処理中止
        If m_ProcessStatus = ProcessStatus.TagSet OrElse m_ProcessStatus = ProcessStatus.Preprocess Then
            'If Not String.IsNullOrEmpty(IcTag.szLotNo) Then
            If IcTag.Status = TagProcessStatus.Ready Then
                m_ProcessStatus = ProcessStatus.Preprocess
                RaiseEvent ProcessStatusChanged(Me, New EventArgs)
            End If

            'End If
        End If
    End Sub

    '照合処理
    Protected Function MatColl(ByVal szCondMat As String, ByVal szEquipMat As String, ByVal idx As Integer) As Boolean
        If szCondMat.Equals(szEquipMat) Then
            m_iScore(idx) = 1
            MatColl = True
        Else
            m_iScore(idx) = 0
            MatColl = False
        End If
        CheckCollScore()
    End Function
    '>> 2017/02/14 佐川 金型連続使用チェック
    Protected Overridable Sub CheckCollScore()
        '<< 2017/02/14 佐川 金型連続使用チェック
        If m_ProcessStatus = ProcessStatus.Preprocess OrElse
            m_ProcessStatus = ProcessStatus.Processing OrElse
            m_ProcessStatus = ProcessStatus.Canceled OrElse
            m_ProcessStatus = ProcessStatus.ManufComplete Then
            Exit Sub
        End If

        Dim sum As Integer = 0
        For Each i As Integer In m_iScore
            sum += i
        Next
        If sum >= PASS_SCORE AndAlso lotCheckFlg = CHECK_OK Then
            OnCollectionDone(EventArgs.Empty)
        Else
            m_fColl = False
        End If
    End Sub

    Overridable Function EndCheck() As Boolean
        EndCheck = True
    End Function
#End Region

#Region "Log"
    Public Sub PutLog(ByVal szSender As String, ByVal szOperator As String, ByVal szMsg As String)
        Dim logRecord As Log

        Dim szLotNo As String
        If String.IsNullOrEmpty(IcTag.szLotNo) Then
            szLotNo = lblLotNo.Text
        Else
            szLotNo = IcTag.szLotNo
        End If

        With logRecord
            .szEquipID = g_EQUIP_NO 'UPD 苗 2018/1/19 装置No.の対応
            .szProcCD = lblProcessCD.Text
            .szLotNo = szLotNo
            .dteOpt = DateTime.Now
            .szOperator = szOperator
            .szControl = szSender.Replace(",", "")
            .szMsg = szMsg
        End With

        PutFileLog(logRecord)
        PutDbLog(logRecord)
    End Sub

    Private Sub PutFileLog(ByVal log As Log)
        Dim sbLog As New StringBuilder

        sbLog.Append(log.szEquipID)
        sbLog.Append(",")
        sbLog.Append(log.szProcCD)
        sbLog.Append(",")
        sbLog.Append(log.szLotNo)
        sbLog.Append(",")
        sbLog.Append(log.dteOpt.ToString(DATE_TIME_FORMAT_DB))
        sbLog.Append(",")
        sbLog.Append(log.szOperator)
        sbLog.Append(",")
        sbLog.Append(log.szControl)
        sbLog.Append(",")
        sbLog.Append(log.szMsg)

        Loging(sbLog)

    End Sub


    ''' <summary>
    ''' ロギング処理
    ''' </summary>
    ''' <remarks>Shift JISで書き込む</remarks>
    Private Shared Sub Loging(ByVal result As StringBuilder)
        '書き込むファイルが既に存在している場合は、ファイルの末尾に追加する
        Dim sw As New System.IO.StreamWriter(GetFullPath() & ".log", True, System.Text.Encoding.GetEncoding(932))
        'TextBox1.Textの内容を書き込む
        sw.WriteLine(DateTime.Now & ":" & result.ToString)
        '閉じる
        sw.Close()
    End Sub
#End Region

#Region "HEX処理"
    Public Function BytesToHexString(ByVal bytes() As Byte) As String
        Dim sb As New StringBuilder
        For Each byteData As Byte In bytes
            sb.Append(FixCharZero(Hex(byteData), 2) & " ")
        Next
        BytesToHexString = sb.ToString.TrimEnd
    End Function

    Public Function BytesToString(ByVal bytes() As Byte) As String
        Dim sb As New StringBuilder
        For Each byteData As Byte In bytes
            If byteData >= &H20 AndAlso byteData <= &H7E Then
                sb.Append(Chr(byteData))
            Else
                sb.Append(" ")
            End If
        Next
        BytesToString = sb.ToString.Trim
    End Function

    Public Function Int16ToBytes(ByVal i As Integer) As Byte()
        Dim szNum As String = FixCharZero(Hex(i), INT_LENGTH * 2).ToArray
        Dim bNum(1) As Byte
        bNum(0) = CInt("&H" & szNum.Substring(0, 2))
        bNum(1) = CInt("&H" & szNum.Substring(2))
        Int16ToBytes = bNum
    End Function

    Public Function StringToBytes(ByVal str As String) As Byte()
        Dim bytes() As Byte = New Byte(str.Length - 1) {}
        Dim i As Integer = 0
        For Each ch As Char In str.ToCharArray
            bytes(i) = Asc(ch)
            i += 1
        Next
        StringToBytes = bytes
    End Function
#End Region

#Region "DEGUB"
    '特性チェックデバッグ用
    Private Sub btnChecked_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChecked.BackColorChanged
        If btnChecked.BackColor = Color.Lime Then
            PutLog(btnChecked.ToString, txtOptNoStt.Text, "特性チェック完成")
        End If
    End Sub
    Private Sub btnSwap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSwap.Click

        'Dim szIePath As String
        'Dim szUrl As String


        'szIePath = GetIniFile("PROD_SWAP", "IE_PATH", """c:\Program Files\Internet Explorer\iexplore.exe""", g_szInitFileName)
        'szUrl = GetIniFile("PROD_SWAP", "URL", "http://172.29.200.64/cs/login.aspx", g_szInitFileName)

        'Shell(String.Format("{0} {1}?EquipID={2}", szIePath, szUrl, g_EQUIP_NO)) 'UPD 苗 2018/1/19 装置No.の対応

        'PutIniFile("PROD_SWAP", "IE_PATH", szIePath, g_szInitFileName)
        'PutIniFile("PROD_SWAP", "URL", szUrl, g_szInitFileName)
        'ADD 苗 2018/4/2 BEING
        If lblProcessCD.Text = PROC_CD_DBA Or lblProcessCD.Text = PROC_CD_WBA Or lblProcessCD.Text = PROC_CD_WBS Then
            '外部EXEを呼び出す
            Dim strPrcCD As String

            strPrcCD = lblProcessCD.Text
            If strPrcCD = PROC_CD_WBS Then strPrcCD = PROC_CD_WBA
            Dim strRetStatus As String
            'm_cEquipMat.killProcess(g_ETKitMangeMix_WCF_WIN) 'Process Kill'DEL MIAO 2018/8/22 
            If String.IsNullOrEmpty(strOptNoEnd) Then
                strRetStatus = Execute_Command(lblProcessCD.Text, EXEC_PG_TAG_CHNG_MTRL, strPrcCD, g_EQUIP_NO, "EMS")
            Else
                strRetStatus = Execute_Command(lblProcessCD.Text, EXEC_PG_TAG_CHNG_MTRL, strPrcCD, g_EQUIP_NO, strOptNoEnd)
            End If


            'ADD 苗 2018/4/2 END
        Else
            'UPD 苗 2018/1/27 BEGIN
            '外部EXEを呼び出す
            Dim ProgName As String
            Dim dtDefExec = m_cData.GetDefExec(COMMON_PROC_CD, EXEC_PG_TAG_CHNG_MTRL)
            If dtDefExec.Rows.Count > 0 Then
                '定義が存在する
                ProgName = dtDefExec.Rows(0)("COMMAND_LINE")
                If Not IsDBNull(dtDefExec.Rows(0)("COMMAND_OPTION")) Then
                    Shell(String.Format(ProgName & " " & dtDefExec.Rows(0)("COMMAND_OPTION"), g_EQUIP_NO, IcTag.szLotNo, txtOptNoStt.Text))
                End If
            End If
            'UPD 苗 2018/1/27 END
        End If


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ', btnSwap.Click

        'Dim InViewLot As New InSiteWebService.InViewLot
        'Dim OutViewLot As New InSiteWebService.OutLotStd

        'InViewLot.Name = lblLotNo.Text

        ''OutViewLot = ViewLotServiceGet(InViewLot)
        'MsgBox(GetCustomerShort)　'DEL 苗 2018/2/27
        'MsgBox(m_cBsiteMess.CheckOnHold(m_szIP).ToString)

        'Dim dt = m_cLotDefect.CheckWarning("D700", "", "FDT", "LQFP1010- 64 CU", {"K813", "K814"})

        'ADD 苗 2018/2/27 BEGIN
        '外部EXEを呼び出す

        'ADD MIAO 2018/8/14 Begin
        ' 着工作業者の空白チェック
        If txtLotNo.Text <> "" Then
            If Not checkBlank(txtOptNoStt.Text, btnOptNoStt.Text) Then
                txtOptNoStt.Focus()
                Exit Sub
            End If
        End If
        'ADD MIAO 2018/8/14 END

        'Dim ProgName As String
        'Dim aryProgName As String() 'ADD 苗 2018/3/26
        'Dim dtDefExec = m_cData.GetDefExec(lblProcessCD.Text, EXEC_PG_TAG_NBIGS) 'UPD MIAO 2019/1/7
        'If dtDefExec.Rows.Count > 0 Then
        '    'ADD 苗 2018/3/26　BEGIN
        '    '定義が存在する
        '    ProgName = dtDefExec.Rows(0)("COMMAND_LINE")
        '    aryProgName = ProgName.Split(";")
        '    For i = 0 To aryProgName.Count - 1
        '        If System.IO.File.Exists(aryProgName(i).ToString) = True Then
        '            ProgName = aryProgName(i).ToString
        '            Exit For
        '        End If
        '    Next
        '    'ADD 苗 2018/3/26　END
        '    If Not IsDBNull(dtDefExec.Rows(0)("COMMAND_OPTION")) Then
        '        Shell(String.Format(ProgName & " " & dtDefExec.Rows(0)("COMMAND_OPTION"), txtLotNo.Text, txtOptNoStt.Text, g_CURRENT_EQUIP_ID, lblPbLayout.Text))
        '    End If
        'End If
        ''ADD 苗 2018/2/27 END
        PutLog(Me.ToString, "NBIGS照合", "BEGIN") '2020/8/8 ver.71
        If LC_COMMAND <> "" Then

            PutLog(Me.ToString, "NBIGS照合", "LC1") '2020/8/8 ver.71
            reconfirmNBIGS = True
            m_cEquipCommandControl.CommandSend(LC_COMMAND)
            Command_LD_Received = False
            ShowCommandWaiting()
        Else
            PutLog(Me.ToString, "NBIGS照合", "LC2") '2020/8/8 ver.71
            reconfirmNBIGS = True
            doLC()
            'Dim tmpLotNo As String = txtLotNo.Text
            'Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)
            'Dim pkgValue As String = getLCPackage()
            'If m_EquipInstPattern <> "00" Then
            '    If pkgValue = "too Much" Then
            '        setCheckInfo("程序被设定多条，请确认。")
            '        Exit Sub
            '    End If
            '    If pkgValue = "" Then
            '        setCheckInfo("没有设定程序，请确认。")
            '        Exit Sub
            '    End If
            'End If
            'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "", lblInputFrm.Text, pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
            '    Command_LD_Received = False
            '    ShowCommandWaiting()
        End If
    End Sub
#End Region

#End Region

    Protected Sub btnTag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTag.Click
        '連続ロット読み込み対応
        LastTag = Nothing
        '>>20170714
        TagDataProcess(sender, {CByte(0)})
        '<<20170714
    End Sub

    'Private Sub dgvLot_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvLot.CellClick
    '    Dim dgv As DataGridView = CType(sender, DataGridView)
    '    Dim komokuName As String = dgv.CurrentCell.Value
    '    Dim activeFlg As Integer = 0
    '    Dim inputMethod As String = String.Empty

    '    For Each dr In dtGridViewMaster.Rows
    '        If dr("KOMOKU_NM").Equals(komokuName) Then
    '            activeFlg = dr("ACTIVE_FLG")
    '            inputMethod = dr("INPUT_METHOD")
    '            Exit For
    '        End If
    '    Next

    '    If activeFlg = 1 Then
    '        Select Case inputMethod
    '            Case "確認"
    '                btnCheck.Enabled = True
    '                btnBarCode.Enabled = False
    '                btnTenKey.Enabled = False
    '                btnSelect.Enabled = False
    '            Case "バーコード"
    '                btnCheck.Enabled = False
    '                btnBarCode.Enabled = True
    '                btnTenKey.Enabled = False
    '                btnSelect.Enabled = False
    '            Case "テンキー"
    '                btnCheck.Enabled = False
    '                btnBarCode.Enabled = False
    '                btnTenKey.Enabled = True
    '                btnSelect.Enabled = False
    '            Case "選択"
    '                btnCheck.Enabled = False
    '                btnBarCode.Enabled = False
    '                btnTenKey.Enabled = False
    '                btnSelect.Enabled = True
    '        End Select
    '    End If
    'End Sub


    ' 2017/05/12 蘇州対応 追加

    ' 初期表示
    Protected Sub setGridView()
        Dim i As Integer = 0

        ' GridViewマスタから表示項目を取得
        Dim dtGridViewLot As DataTable = m_cData.GetGridViewLot(lblProcessCD.Text)

        ' GridViewマスタ取得項目を保持
        dtGridViewMaster = dtGridViewLot.Copy()

        ' GridViewマスタ項目数を保持
        dtRowsCount = dtGridViewLot.Rows.Count

        ' LOTタブに項目が存在しない場合，初期表示タブを設備にしLotタブのチェックフラグをOKにする
        TabPageLot.Enabled = True
        lotCheckFlg = 0
        If dtRowsCount = 0 Then
            TabPageLot.Enabled = False
            lotCheckFlg = 1
        End If

        If dgvLot.DataSource IsNot Nothing Then
            dgvLot.Columns("colItem").DataPropertyName = ""
            dgvLot.Columns("condTag").DataPropertyName = ""
            dgvLot.Columns("getCondFlg").DataPropertyName = ""
            dgvLot.Columns("keyPad").DataPropertyName = ""
            dgvLot.Columns("selectWindow").DataPropertyName = ""
        End If

        ' GridViewマスタ項目数分，Grid列を生成
        If dtGridViewLot.Rows.Count <> 0 Then
            dgvLot.DataSource = dtGridViewLot
            dgvLot.Columns("colItem").DataPropertyName = "KOUMOKU_NM"
            dgvLot.Columns("condTag").DataPropertyName = "MNF_CND_TAG"
            dgvLot.Columns("getCondFlg").DataPropertyName = "MNF_CND_GET_KBN"
            dgvLot.Columns("keyPad").DataPropertyName = "KEYPAD"
            dgvLot.Columns("selectWindow").DataPropertyName = "SELECT_WINDOW"
        End If

        ' 項目数ラベルの表示（項目数：XX）
        Dim reg As New System.Text.RegularExpressions.Regex("[0-9]")
        lblItemNum.Text = reg.Replace(lblItemNum.Text, "")
        lblItemNum.Text = lblItemNum.Text & dtGridViewLot.Rows.Count.ToString

        ' 初期表示（ロットNo非入力）時は全ボタン非活性
        btnCheck.Enabled = False
        btnBarCodeGrid.Enabled = False
        btnTenKey.Enabled = False
        btnSelect.Enabled = False
        btnUp.Enabled = False
        btnDown.Enabled = False

    End Sub

    ' ロットNoを入力した際に製造条件・現物型式をクリアする
    Protected Sub clearActualModel()
        For i = 0 To dtRowsCount - 1
            dgvLot.Rows(i).Cells(COND_CELL).Value = String.Empty
            dgvLot.Rows(i).Cells(RESULT_CELL).Value = String.Empty
            dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = NORMAL_INIT_COLOR
        Next
    End Sub

    ' ロットNo入力時と着工時にボタンの活性・非活性を切り替える（各画面「GetDataByIcTag()」で呼び出し）
    Protected Sub setGridViewLot()

        If dtRowsCount = 0 Then
            Exit Sub
        End If

        ' 各項目行に対して入力必須色（黄色）の設定，入力チェックの設定を行う
        For i = 0 To dtRowsCount - 1
            If IcTag.Status = TagProcessStatus.Ready Then
                ' ステータスが着工前の場合
                If dtGridViewMaster.Rows(i)("BEGIN_ACTIVE_FLG") = ACTIVE Then
                    ' 着工_ボタン活性フラグが「1」の場合，背景色を黄色・チェックフラグをNG(0)に設定
                    If dtGridViewMaster.Rows(i)("INPUT_METHOD") = METHOD_BARCODE Then
                        ' バーコードは橙色で表示
                        dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = BARCODE_INIT_COLOR
                    Else
                        dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = Color.Yellow
                    End If
                    dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_NG
                Else
                    ' 着工_ボタン活性フラグが「0」の場合，チェックフラグをスルー(2)に設定
                    dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_THROUGH
                End If

            Else
                ' ステータスが着工前以外の場合
                If dtGridViewMaster.Rows(i)("COMPLETE_ACTIVE_FLG") = ACTIVE Then
                    ' 完成_ボタン活性フラグが「1」の場合，背景色を黄色・チェックフラグをNG(0)に設定
                    If dtGridViewMaster.Rows(i)("INPUT_METHOD") = METHOD_BARCODE Then
                        ' バーコードは橙色で表示
                        dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = BARCODE_INIT_COLOR
                    Else
                        dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = Color.Yellow
                    End If
                    dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_NG
                Else
                    ' 完成_ボタン活性フラグが「0」の場合，チェックフラグをスルー(2)に設定
                    dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_THROUGH
                End If

            End If
        Next

        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex
        If currentRow = 0 Then
            btnUp.Enabled = False
        Else
            btnUp.Enabled = True
        End If

        If currentRow <> dtRowsCount - 1 Then
            btnDown.Enabled = True
        Else
            btnDown.Enabled = False
        End If

        Dim komokuName As String = dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value

        ' ボタン活性化
        btnActivate(komokuName)

        dgvLot.Enabled = True

        ' 全項目活性フラグが「0」の場合にcheckFlgを「1」にする
        checkAllCell()

    End Sub

    ' UPボタンクリック処理
    Private Sub btnUp_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUp.Click
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        If currentRow = 0 Then
            Exit Sub
        End If

        ' 現在行を一行上に移動する
        dgvLot.CurrentCell = dgvLot(0, currentRow - 1)
        Dim komokuName As String = dgvLot.Rows(currentRow - 1).Cells(KOMOKU_CELL).Value

        btnActivate(komokuName)

        btnDown.Enabled = True

        currentRow = dgvLot.CurrentCell.RowIndex
        ' 移動後現在行が先頭行の場合，UPボタンを非活性化
        If currentRow = 0 Then
            btnUp.Enabled = False
        End If
    End Sub

    ' DOWNボタンクリック処理
    Private Sub btnDown_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDown.Click
        Dim currentRow As Integer
        Dim maxRowCount As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        maxRowCount = dtRowsCount - 1
        If currentRow = maxRowCount Then
            Exit Sub
        End If

        ' 現在行を一行下に移動する
        dgvLot.CurrentCell = dgvLot(0, currentRow + 1)
        Dim komokuName As String = dgvLot.Rows(currentRow + 1).Cells(KOMOKU_CELL).Value

        btnActivate(komokuName)

        btnUp.Enabled = True

        currentRow = dgvLot.CurrentCell.RowIndex
        ' 移動後現在行が最終行の場合，DOWNボタンを非活性化
        If currentRow = maxRowCount Then
            btnDown.Enabled = False
        End If
    End Sub

    ' 選択セルによるボタン活性/非活性の切り替え処理
    Private Sub btnActivate(ByVal komokuName As String)
        Dim activeFlg As Integer = 0
        Dim inputMethod As String = String.Empty

        For Each dr In dtGridViewMaster.Rows
            ' 現在行の項目名と保持しているGridViewマスタの項目名を比較
            If dr("KOUMOKU_NM").Equals(komokuName) Then
                ' 合致した場合
                If IcTag.Status = TagProcessStatus.Ready Then
                    ' ステータスが着工前の場合，着工_ボタン活性フラグを代入
                    activeFlg = dr("BEGIN_ACTIVE_FLG")
                Else
                    ' ステータスが着工前以外の場合，完成_ボタン活性フラグを代入
                    activeFlg = dr("COMPLETE_ACTIVE_FLG")
                End If

                ' 入力方法
                inputMethod = dr("INPUT_METHOD")
                Exit For
            End If
        Next

        'テンキーを開いたまま行移動した場合、テンキーを閉じる
        If PanelTenKey_Grid.Visible Then
            PanelTenKey_Grid.Visible = False
        End If

        If activeFlg = ACTIVE Then
            ' 活性フラグが「1」の場合，入力方法でボタンを活性化する
            Select Case inputMethod
                Case METHOD_CONFIRM
                    ' 確認
                    btnCheck.Enabled = True
                    btnBarCodeGrid.Enabled = False
                    btnTenKey.Enabled = False
                    btnSelect.Enabled = False
                Case METHOD_BARCODE
                    ' バーコード
                    btnCheck.Enabled = False
                    btnBarCodeGrid.Enabled = True
                    btnTenKey.Enabled = False
                    btnSelect.Enabled = False
                Case METHOD_TENKEY
                    ' テンキー
                    btnCheck.Enabled = False
                    btnBarCodeGrid.Enabled = False
                    btnTenKey.Enabled = True
                    btnSelect.Enabled = False
                Case METHOD_SELECT
                    ' 選択
                    btnCheck.Enabled = False
                    btnBarCodeGrid.Enabled = False
                    btnTenKey.Enabled = False
                    btnSelect.Enabled = True
                Case Else
                    btnCheck.Enabled = False
                    btnBarCodeGrid.Enabled = False
                    btnTenKey.Enabled = False
                    btnSelect.Enabled = False

            End Select
        Else
            btnCheck.Enabled = False
            btnBarCodeGrid.Enabled = False
            btnTenKey.Enabled = False
            btnSelect.Enabled = False
        End If

        ' 確認不要の場合，確認ボタンを非活性にする
        Try
            If Not IsNothing(dgvLot.Rows(dgvLot.CurrentCell.RowIndex).Cells(CHECKRESULT_CELL).Value) AndAlso
                dgvLot.Rows(dgvLot.CurrentCell.RowIndex).Cells(CHECKRESULT_CELL).Value.Equals(NOTCHECKED) Then
                btnCheck.Enabled = False
            End If
        Catch
        End Try

    End Sub

    ' 確認ボタンクリック処理
    Private Sub btnCheck_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCheck.Click
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        If String.IsNullOrEmpty(dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value) Then
            ' 現物型式セルが空白の場合，「確認済み」を表示し，チェックフラグをOK(1)に設定
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00054")
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ENTERED_INIT_COLOR
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK
            dgvLot.Rows(currentRow).Cells(CHECKRESULT_CELL).Value = CHECKED
        Else
            ' 現物型式セルが空白でない場合，セルを空白にし，チェックフラグをNG(0)に設定
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = String.Empty
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = Color.Yellow
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
            dgvLot.Rows(currentRow).Cells(CHECKRESULT_CELL).Value = NOTCONFIRMED
        End If

        ' 現在行を一行下に移動する
        moveCurrentCell(currentRow)

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    ' 選択ボタンクリック処理
    Private Sub btnSelect_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSelect.Click
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex
        Dim komokuName As String = dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value

        ' 選択画面によって，表示する別画面を決定する
        Select Case dgvLot.Rows(currentRow).Cells(SELWINDOW_CELL).Value
            Case OK_NG
                ' OK/NG
                select_Window_OK_NG()
            Case WAFER
                ' ウェハ径
                select_Window_Wafer()
            Case INSP_METHOD
                ' 検査方法
                select_Window_InspMethod()
            Case ZONE
                ' ZONE
                select_Window_Zone()
        End Select

    End Sub

    ' 選択ボタン：OK_NG表示処理
    Private Sub select_Window_OK_NG()
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        Select Case SelectDialog(SelectType.OK_NG, htMsgMst)
            Case DialogResult.OK
                ' OKボタンが押下された場合，OKを表示し，チェックフラグをOK(1)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = OK
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ENTERED_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK
            Case DialogResult.No
                ' NGボタンが押下された場合，NGを表示し，チェックフラグをNG(0)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = NG
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ERROR_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
            Case DialogResult.Cancel
                ' クリアボタンが押下された場合,セルを空白にし，チェックフラグをNG(0)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = String.Empty
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = TENKEY_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
        End Select

        ' 現在行を一行下に移動する
        moveCurrentCell(currentRow)

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    ' 選択ボタン：ウェハ径表示処理
    Private Sub select_Window_Wafer()
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        Select Case SelectDialog(SelectType.Wafer, htMsgMst)
            ' 各ボタンが押下された場合，値を表示する
            Case SelectResult.IN5
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = "5"
            Case SelectResult.IN6
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = "6"
            Case SelectResult.IN8
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = "8"
            Case SelectResult.IN12
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = "12"
        End Select

        ' 現物型式のチェック処理を行う
        If checkCell(currentRow) Then
            ' エラーがなかった場合，チェックフラグをOK(1)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK

            ' 現在行を一行下に移動する
            moveCurrentCell(currentRow)
        Else
            ' エラーがあった場合，チェックフラグをNG(0)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
        End If

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    ' 選択ボタン：検査方法表示処理
    Private Sub select_Window_InspMethod()
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        Select Case SelectDialog(SelectType.WaferCheck, htMsgMst)
            Case SelectResult.WaferCorss
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00076")
            Case SelectResult.Wafer4P
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00077")
            Case SelectResult.WaferNone
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00078")
        End Select

        ' 現物型式のチェック処理を行う
        If checkCell(currentRow) Then
            ' エラーがなかった場合，チェックフラグをOK(1)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK

            ' 現在行を一行下に移動する
            moveCurrentCell(currentRow)
        Else
            ' エラーがあった場合，チェックフラグをNG(0)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
        End If

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    ' 選択ボタン：ZONE表示処理
    Private Sub select_Window_Zone()
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        Select Case SelectDialog(SelectType.ZONE, htMsgMst)
            Case DialogResult.OK
                ' ZONE1ボタンが押下された場合，ZONE1を表示し，チェックフラグをOK(1)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00104")
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ENTERED_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK
            Case DialogResult.No
                ' ZONE2ボタンが押下された場合，ZONE2を表示し，チェックフラグをOK(1)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = getMsgStr("MSG00105")
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ENTERED_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK
            Case DialogResult.Cancel
                ' クリアボタンが押下された場合,セルを空白にし，チェックフラグをNG(0)に設定
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = String.Empty
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = TENKEY_INIT_COLOR
                dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
        End Select

        ' 現在行を一行下に移動する
        moveCurrentCell(currentRow)

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    ' テンキーボタンクリック処理
    Private Sub btnTenKey_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnTenKey.Click
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        For Each childControl As Control In Controls
            If TypeOf childControl Is TenKey Then
                childControl.Dispose()
            End If

        Next childControl

        PanelTenKey.Visible = False

        m_DelayType = DelayType.Tenkey

        CallTenKey_Grid(currentRow)

        btnUp.Enabled = False
        btnDown.Enabled = False

    End Sub

    Protected Sub CallTenKey_Grid(ByVal currentRow As Integer)
        PanelTenKey_Grid.Top = btnTenKey.Bottom + 90
        PanelTenKey_Grid.Left = btnTenKey.Right + 15
        'lblInput.BackColor = Color.Cyan
        'Dim iDifTop As Integer = 0
        'If lblInput.Parent.Name.ToUpper.StartsWith("TAB") Then
        '    iDifTop = lblInput.Parent.Parent.Top + lblInput.Parent.Top
        'End If
        'PanelTenKey.Top = iDifTop + lblInput.Bottom + 5
        'PanelTenKey.Left = lblInput.Right - PanelTenKey.Width
        'If PanelTenKey.Left < 0 Then
        '    PanelTenKey.Left = 0
        'End If
        '蘇州対応　2017/04/26 maruyama@tmc
        'フレーム幅をはみ出さないよう修正
        'If PanelTenKey.Bottom > Me.Height - SystemInformation.CaptionHeight - (SystemInformation.FrameBorderSize.Height * 2) Then
        '    PanelTenKey.Top = lblInput.Top - PanelTenKey.Height - 5 + iDifTop
        'End If
        PanelTenKey_Grid.Visible = True

        '蘇州対応　2017/05/25 F.Gotou
        'テンキー：｢M｣、｢W｣ボタン追加
        Select Case dgvLot.Rows(currentRow).Cells(KEYPAD_CELL).Value
            Case TENKEY_INT
                btnBar_Grid.Enabled = False
                btnDot_Grid.Enabled = False
                btnL_Grid.Enabled = False
                btnM_Grid.Enabled = False
                btnW_Grid.Enabled = False
                btnSlash_Grid.Enabled = False
            Case TENKEY_DEC
                btnBar_Grid.Enabled = False
                btnDot_Grid.Enabled = True
                btnL_Grid.Enabled = False
                btnM_Grid.Enabled = False
                btnW_Grid.Enabled = False
                btnSlash_Grid.Enabled = False
            Case TENKEY_HYPHEN
                btnBar_Grid.Enabled = True
                btnDot_Grid.Enabled = True
                btnL_Grid.Enabled = False
                btnM_Grid.Enabled = False
                btnW_Grid.Enabled = False
                btnSlash_Grid.Enabled = False
        End Select

        TenkeyText_Grid.Text = dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value
        TenkeyText_Grid.Focus()
        TenkeyText_Grid.Select(TenkeyText_Grid.Text.Length, 0)

    End Sub

    Protected btnKeyAry_Grid() As System.Windows.Forms.Button
    Protected Sub InitTenKey_Grid()
        PanelTenKey_Grid.Visible = False
        PanelTenKey_Grid.BringToFront()
        btnKeyAry_Grid = New System.Windows.Forms.Button(9) {}
        For i = 0 To 9
            btnKeyAry_Grid(i) = CType(PanelTenKey_Grid.Controls("btn" & i & "_Grid"), Button)
        Next
        btnC_Grid = CType(PanelTenKey_Grid.Controls("btnC_Grid"), Button)
        btnE_Grid = CType(PanelTenKey_Grid.Controls("btnE_Grid"), Button)
        btnM_Grid = CType(PanelTenKey_Grid.Controls("btnM_Grid"), Button)
        btnW_Grid = CType(PanelTenKey_Grid.Controls("btnW_Grid"), Button)
        btnSlash_Grid = CType(PanelTenKey_Grid.Controls("btnSlash_Grid"), Button)
        For i = 0 To btnKeyAry_Grid.Length - 1
            AddHandler btnKeyAry_Grid(i).Click, AddressOf btnKeyAry_Click_Grid
        Next i
        AddHandler btnC_Grid.Click, AddressOf btnC_Click_Grid
        AddHandler btnE_Grid.Click, AddressOf btnE_Click_Grid
        AddHandler btnBar_Grid.Click, AddressOf btnbar_Click_Grid
        AddHandler btnL_Grid.Click, AddressOf btnL_Click_Grid
        AddHandler btnM_Grid.Click, AddressOf btnM_Click_Grid
        AddHandler btnW_Grid.Click, AddressOf btnW_Click_Grid
        AddHandler btnDot_Grid.Click, AddressOf btnDot_Click_Grid
        AddHandler btnSlash_Grid.Click, AddressOf btnSlash_Click_Grid

        'AddHandler lblCompleteCnt.Click, AddressOf tkl_Click
        'AddHandler lblFailedCnt.Click, AddressOf tkl_Click
        'AddHandler lblPcbCnt.Click, AddressOf tkl_Click
        'AddHandler lblCrossCnt.Click, AddressOf tkl_Click

    End Sub

    ' テンキー画面：「数字」ボタンクリック処理
    Protected Sub btnKeyAry_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btnKey As Button = CType(sender, Button)
        Dim strKey As String = btnKey.Text

        'If String.IsNullOrEmpty(TenkeyText_Grid.Text) _
        '                OrElse TenkeyText_Grid.Text.Equals("0") Then
        '    TenkeyText_Grid.Text = strKey
        'Else
        TenkeyText_Grid.Text &= strKey
        'End If
    End Sub

    ' テンキー画面：「．」ボタンクリック処理
    Private Sub btnDot_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot_Grid.Click
        Try
            Dim chrArr() As Char = TenkeyText_Grid.Text.ToCharArray
            For Each chara As Char In chrArr
                If chara = CChar(".") Then
                    Exit Sub
                End If
            Next
            TenkeyText_Grid.Text &= "."
        Catch
            Exit Sub
        End Try

    End Sub

    ' テンキー画面：「CLR」ボタンクリック処理
    Protected Sub btnC_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text = String.Empty
    End Sub

    ' テンキー画面：「-」ボタンクリック処理
    Protected Sub btnbar_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text &= "-"
    End Sub

    ' テンキー画面：「L」ボタンクリック処理
    Protected Sub btnL_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text &= "L"
    End Sub

    '蘇州対応　2017/05/25 F.Gotou
    ' テンキー画面：「M」ボタンクリック処理
    Protected Sub btnM_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text = "M"
    End Sub

    ' テンキー画面：「W」ボタンクリック処理
    Protected Sub btnW_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text = "W"
    End Sub

    ' テンキー画面：「/」ボタンクリック処理
    Protected Sub btnSlash_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TenkeyText_Grid.Text &= "/"
    End Sub

    ' テンキー画面：「Ent」ボタンクリック処理
    Protected Sub btnE_Click_Grid(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex
        dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = Color.Empty
        dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value = TenkeyText_Grid.Text
        PanelTenKey_Grid.Visible = False
        TenKeyDone_Grid()

        ' 現物型式のチェック処理を行う
        If checkCell(currentRow) Then
            ' エラーがなかった場合，チェックフラグをOK(1)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK

            ' 現在行を一行下に移動する
            moveCurrentCell(currentRow)
        Else
            ' エラーがあった場合，チェックフラグをNG(0)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
            If currentRow = 0 Then
                btnUp.Enabled = False
            Else
                btnUp.Enabled = True
            End If

            If currentRow <> dtRowsCount - 1 Then
                btnDown.Enabled = True
            Else
                btnDown.Enabled = False
            End If
        End If

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    Overridable Sub TenKeyDone_Grid()

    End Sub

    'Protected Function CheckNum() As Boolean
    '    If IsNumeric(lblInput.Text) Then
    '        CheckNum = True
    '    Else
    '        CheckNum = False
    '    End If
    'End Function

    ' バーコードボタンクリック処理
    Private Sub btnBarCodeGrid_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBarCodeGrid.Click
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        ' カレントセルを現物型式セルに移動
        dgvLot.CurrentCell = dgvLot.Rows(currentRow).Cells(RESULT_CELL)

        ' カレントセルを編集モードにする
        dgvLot.BeginEdit(True)

    End Sub

    Delegate Sub dgcDelegate(ByVal currentRow As Integer)
    ' バーコードEnterキー押下処理
    Private Sub DataGridView_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dgvLot.CellEndEdit
        Dim currentRow As Integer
        currentRow = dgvLot.CurrentCell.RowIndex

        ' 現物型式のチェック処理を行う
        If checkCell(currentRow) Then
            ' エラーがなかった場合，チェックフラグをOK(1)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_OK

            ' 現在行を一行下に移動する
            dgvLot.BeginInvoke(New dgcDelegate(AddressOf moveCurrentCell), currentRow)
        Else
            ' エラーがあった場合，チェックフラグをNG(0)に設定
            dgvLot.Rows(currentRow).Cells(CHECK_CELL).Value = CHECK_NG
            If e.RowIndex < dgvLot.RowCount - 1 AndAlso
                e.RowIndex <> 0 Then
                SendKeys.Send("{UP}")
            End If
        End If

        ' ロットタブ全体のチェック処理を行う
        If checkAllCell() Then
            CheckCollScore()
        End If

    End Sub

    Private Sub DataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles dgvLot.EditingControlShowing

        If TypeOf e.Control Is DataGridViewTextBoxEditingControl Then
            Dim dgv As DataGridView = CType(sender, DataGridView)
            Dim editingControl As DataGridViewTextBoxEditingControl = CType(e.Control, DataGridViewTextBoxEditingControl)

            RemoveHandler editingControl.KeyPress, AddressOf dataGridViewTextBox_KeyPress

            If dgv.CurrentCell.OwningColumn.Name = "colResult" Then
                AddHandler editingControl.KeyPress, AddressOf dataGridViewTextBox_KeyPress
            End If
        End If

    End Sub

    Private Sub dataGridViewTextBox_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If
    End Sub


    ' 各ボタン用セル移動処理
    Private Sub moveCurrentCell(ByVal currentRow As Integer)
        ' 現在行が最終行ではない場合
        If currentRow <> dtRowsCount - 1 Then
            ' 現在行を一行下に移動する
            dgvLot.CurrentCell = dgvLot(0, currentRow + 1)

            Dim komokuName As String = dgvLot.Rows(currentRow + 1).Cells(KOMOKU_CELL).Value
            ' ボタン活性化
            btnActivate(komokuName)

            ' 移動後最終行でない場合
            If dgvLot.CurrentCell.RowIndex <> dtRowsCount - 1 Then
                ' DOWNボタンを活性化
                btnDown.Enabled = True
            Else
                btnDown.Enabled = False
            End If
        Else
            If currentRow = 0 Then
                btnUp.Enabled = False
            Else
                btnUp.Enabled = True
            End If
        End If
    End Sub

    ' チェック処理
    Private Function checkCell(ByVal currentRow As Integer) As Boolean
        Dim komokuName As String = dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value
        Dim input_chk_flg As Integer = 0
        Dim value_chk_flg As Integer = 0
        Dim type_chk_flg As Integer = 0
        Dim type As String = String.Empty
        Dim checkFlg As Integer = CHECK_OK

        For Each dr In dtGridViewMaster.Rows
            If dr("KOUMOKU_NM").Equals(komokuName) Then
                If IcTag.Status = TagProcessStatus.Ready Then
                    ' ステータスが着工前の場合
                    input_chk_flg = dr("BEGIN_INPUT_CHK_FLG")
                    value_chk_flg = dr("BEGIN_MATCH_CHK_FLG")
                    type_chk_flg = dr("BEGIN_TYPE_CHK_FLG")
                    If Not String.IsNullOrEmpty(dr("DATA_TYPE").ToString) Then
                        type = dr("DATA_TYPE")
                    End If
                    Exit For
                Else
                    ' ステータスが着工前以外の場合
                    input_chk_flg = dr("COMPLETE_INPUT_CHK_FLG")
                    value_chk_flg = dr("COMPLETE_MATCH_CHK_FLG")
                    type_chk_flg = dr("COMPLETE_TYPE_CHK_FLG")
                    If Not String.IsNullOrEmpty(dr("DATA_TYPE").ToString) Then
                        type = dr("DATA_TYPE")
                    End If
                    Exit For
                End If
            End If
        Next

        ' 入力チェック
        If input_chk_flg = 1 Then
            If inputCheck(currentRow) Then
                checkFlg = CHECK_OK
            Else
                checkFlg = CHECK_NG
                Return False
            End If
        End If

        ' 値チェック
        If value_chk_flg = 1 Then
            If valueCheck(currentRow) Then
                checkFlg = CHECK_OK
            Else
                checkFlg = CHECK_NG
                Return False
            End If
        End If

        ' 型チェック
        If type_chk_flg = 1 Then
            If typeCheck(currentRow, type) Then
                checkFlg = CHECK_OK
            Else
                checkFlg = CHECK_NG
                Return False
            End If
        End If

        ' 全チェックが通れば背景色を変更しTrueを返す
        If checkFlg = CHECK_OK Then
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ENTERED_INIT_COLOR
            Return True
        End If

        Return False
    End Function

    ' 入力チェック
    Private Function inputCheck(ByVal currentRow As Integer) As Boolean
        ' 現物型式が空白の場合エラー
        If String.IsNullOrEmpty(dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value) Then
            MsgBox(getMsgStr("MSG00020", dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value))
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        Return True
    End Function

    ' 値チェック
    Private Function valueCheck(ByVal currentRow As Integer) As Boolean
        ' 製造条件が空「-」の時はエラーとしない
        If dgvLot.Rows(currentRow).Cells(COND_CELL).Value.Equals(HYPHEN) Then
            Return True
        End If

        ' 現物型式と製造条件の値が異なる場合エラー
        If Not dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value.Equals(dgvLot.Rows(currentRow).Cells(COND_CELL).Value) Then
            MsgBox(getMsgStr("MSG00021", dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value))
            dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        Return True
    End Function

    ' 型チェック
    Private Function typeCheck(ByVal currentRow As Integer, ByVal type As String) As Boolean
        ' 現物型式の型がマスタの型と異なる場合エラー
        If type.Equals(TYPE_DATE) Then
            ' 日付型チェック
            If Not IsDate(dgvLot.Rows(currentRow).Cells(RESULT_CELL).Value) Then
                MsgBox(getMsgStr("MSG00048", dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value))
                dgvLot.Rows(currentRow).Cells(RESULT_CELL).Style.BackColor = ERROR_INIT_COLOR
                Return False
            End If
        End If

        Return True
    End Function

    Private Function checkAllCell() As Boolean
        Dim i As Integer

        For i = 0 To dtRowsCount - 1
            If dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_NG Then
                lotCheckFlg = CHECK_NG
                Return False
            End If
        Next

        lotCheckFlg = CHECK_OK

        Return True

    End Function

    ' 言語指定でメッセージを取得し，HashTableに積む
    'Private Sub setAllErrMsg(ByVal lang As String)
    '    If htMsgMst.Count = 0 Then
    '        Dim dtMsgMst As DataTable = m_cLotInfo.GetAllMsg(lang)
    '        For Each dr In dtMsgMst.Rows
    '            With htMsgMst
    '                .Add(dr("MESSAGE_ID"), dr("MESSAGE"))
    '            End With
    '        Next
    '    End If
    'End Sub

    '>> 2018/02/19 安部 固定メッセージをメッセージマスタから取得に変更
    '   処理をmod_Common に移動
    '
    ' メッセージのHashTableから指定されたメッセージIDと変数によりメッセージを返す
    'Public Function getMsgStr(ByVal msgId As String, Optional ByVal args1 As String = "", Optional ByVal args2 As String = "") As String

    '    If String.IsNullOrEmpty(args1) AndAlso String.IsNullOrEmpty(args2) Then
    '        getMsgStr = htMsgMst(msgId)
    '        Exit Function

    '    ElseIf Not String.IsNullOrEmpty(args1) AndAlso String.IsNullOrEmpty(args2) Then
    '        getMsgStr = String.Format(htMsgMst(msgId), args1)
    '        Exit Function

    '    Else
    '        getMsgStr = String.Format(htMsgMst(msgId), args1, args2)
    '        Exit Function
    '    End If

    'End Function
    '<< 2018/02/19 安部 固定メッセージをメッセージマスタから取得に変更

    Private Sub currentCellChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dgvLot.CurrentCellChanged
        Dim currentRow As Integer
        Try
            If dgvLot.CurrentCell Is Nothing Then
                Exit Sub
            End If

            currentRow = dgvLot.CurrentCell.RowIndex

            Dim komokuName As String = dgvLot.Rows(currentRow).Cells(KOMOKU_CELL).Value

            btnActivate(komokuName)

            If currentRow = 0 Then
                btnUp.Enabled = False
            Else
                btnUp.Enabled = True
            End If

            If currentRow <> dtRowsCount - 1 Then
                btnDown.Enabled = True
            Else
                btnDown.Enabled = False
            End If

        Catch
            Exit Sub
        End Try

    End Sub

    ' DB更新処理
    ' テーブルにフィールドを追加
    Private Sub addColumnsDataTable()
        dtDBUpd = New DataTable
        dtDBUpd.Columns.Add("MNF_CND_TAG")      ' 製造条件TAG
        dtDBUpd.Columns.Add("MNF_CND_TAG_FLG")  ' 製造条件TAGフラグ
        dtDBUpd.Columns.Add("SEQ")              ' SEQ（項目）
        dtDBUpd.Columns.Add("MNF_CONDITION")    ' 製造条件
        dtDBUpd.Columns.Add("ACTUAL_MODEL")     ' 現物型式
        dtDBUpd.Columns.Add("MANAGEMENT_NO")    ' 管理番号
        dtDBUpd.Columns.Add("MATERIAL_LOT")     ' 材料ロット
        dtDBUpd.Columns.Add("LIMIT_TIME")       ' 使用期限
    End Sub

    ' LOTタブのデータをDataTableにセットする
    Protected Sub setLotData()
        dtDBUpd.Clear()
        For i = 0 To dtRowsCount - 1
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(i)("MNF_CND_TAG") = dgvLot.Rows(i).Cells(CONDTAG_CELL).Value
            If dgvLot.Rows(i).Cells(GETCONDFLG_CELL).Value = JYOKEN Then
                dtDBUpd.Rows(i)("MNF_CND_TAG_FLG") = CND_TAG_FLG_JYOKEN
            Else
                dtDBUpd.Rows(i)("MNF_CND_TAG_FLG") = CND_TAG_FLG_ELSE
            End If
            dtDBUpd.Rows(i)("SEQ") = DB_SEQ_LOT
            dtDBUpd.Rows(i)("MNF_CONDITION") = dgvLot.Rows(i).Cells(COND_CELL).Value
            If dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_CONFIRM) Then
                If dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value.Equals(CHECKED) Then
                    dtDBUpd.Rows(i)("ACTUAL_MODEL") = CHECKED
                ElseIf dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value.Equals(NOTCHECKED) Then
                    dtDBUpd.Rows(i)("ACTUAL_MODEL") = NOTCHECKED
                Else
                    dtDBUpd.Rows(i)("ACTUAL_MODEL") = ""
                End If
            ElseIf dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_ZUKEI) Then
                dtDBUpd.Rows(i)("ACTUAL_MODEL") = ""
            Else
                dtDBUpd.Rows(i)("ACTUAL_MODEL") = dgvLot.Rows(i).Cells(RESULT_CELL).Value
            End If
        Next
    End Sub

    ' 製造条件表示
    Protected Sub setJyokenData()
        dtJyokenData = New DataTable
        dtJyokenData = m_cData.GetJyokenData(txtLotNo.Text, m_szProc)

        Dim prelotNo As String = SelectPreLotNo()
        setCondData(prelotNo)

    End Sub
    Protected Sub setJyokenALLData(lotno As String)
        dtJyokenData = New DataTable
        dtJyokenData = m_cData.GetJyokenALLData(lotno)

        Dim prelotNo As String = SelectPreLotNo()
        setCondData(prelotNo)

    End Sub
    ' GridViewに製造条件を表示
    Private Sub setCondData(ByVal lotNo As String)
        Dim i As Integer = 0

        ' 前工程の明細テーブルからデータを取得
        getPreDetail(lotNo)

        ' GridViewの項目数分ループ
        For i = 0 To dtRowsCount - 1
            dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value = NOTCONFIRMED
            ' l_jyokendataから取得する場合
            If dgvLot.Rows(i).Cells(GETCONDFLG_CELL).Value = JYOKEN Then
                'グリッドマスタ分ループ
                For Each dr In dtGridViewMaster.Rows
                    '項目名が一致する場合
                    If dr("KOUMOKU_NM").Equals(dgvLot.Rows(i).Cells(KOMOKU_CELL).Value) Then
                        ' 「表示」項目の場合，現物型式に「-」を表示する
                        ' 入力方法
                        If dr("INPUT_METHOD").Equals(METHOD_HYOJI) Then
                            dgvLot.Rows(i).Cells(RESULT_CELL).Value = HYPHEN
                        End If
                        ' l_jyokendata数分ループ
                        For Each drJyoken In dtJyokenData.Rows
                            ' GridViewの製造条件TAGとl_jyokendataテーブルの項目名を比較
                            If dgvLot.Rows(i).Cells(CONDTAG_CELL).Value.Equals(drJyoken("KOMOKUNAME")) And
                                drJyoken("KOTEI").Equals(m_szProc) Then
                                ' 一致した場合，GridViewに製造条件を表示する
                                dgvLot.Rows(i).Cells(COND_CELL).Value = drJyoken("KOMOKUDATA")

                                If dr("INPUT_METHOD").Equals(METHOD_ZUKEI) Then
                                    dgvLot.Rows(i).Cells(RESULT_CELL).Dispose()
                                    ' 「図形」項目の場合，現物型式に画像を表示する
                                    Dim imageName As String = m_szImagePath & drJyoken("KOMOKUDATA").ToString
                                    If System.IO.File.Exists(imageName) Then
                                        Dim imageCell As DataGridViewImageCell = New DataGridViewImageCell
                                        imageCell.ImageLayout = DataGridViewImageCellLayout.Stretch
                                        dgvLot.Rows(i).Cells(RESULT_CELL) = imageCell
                                        dgvLot.Rows(i).Cells(RESULT_CELL).Value = New Bitmap(imageName)
                                    End If
                                End If
                                Exit For
                            End If
                        Next
                        Exit For
                    End If
                Next
                If dgvLot.Rows(i).Cells(SELWINDOW_CELL).Value.Equals(OK_NG) Then
                    ' 「選択」項目のOK/NGの場合，製造条件に"OK/NG"を表示
                    dgvLot.Rows(i).Cells(COND_CELL).Value = COND_OKNG
                ElseIf dgvLot.Rows(i).Cells(SELWINDOW_CELL).Value.Equals(ZONE) Then
                    ' 「選択」項目のZONEの場合，製造条件に"ZONE1/ZONE2"を表示
                    dgvLot.Rows(i).Cells(COND_CELL).Value = COND_ZONE
                End If
            ElseIf dgvLot.Rows(i).Cells(GETCONDFLG_CELL).Value = PREKOTEI Then
                For Each dr In dtGridViewMaster.Rows
                    ' 入力方法
                    If dr("INPUT_METHOD").Equals(METHOD_HYOJI) Then
                        dgvLot.Rows(i).Cells(RESULT_CELL).Value = HYPHEN
                    End If
                Next
                ' 前工程から取得する場合
                For Each drPreDetail In dtPreDetailData.Rows
                    If dgvLot.Rows(i).Cells(CONDTAG_CELL).Value.Equals(drPreDetail("MNF_CND_TAG")) Then
                        dgvLot.Rows(i).Cells(COND_CELL).Value = drPreDetail("ACTUAL_MODEL")
                        Exit For
                    End If
                Next
            End If
            ' l_jyokendataに存在しない場合ハイフンを表示する
            If dgvLot.Rows(i).Cells(GETCONDFLG_CELL).Value.ToString = JYOKEN _
                AndAlso String.IsNullOrEmpty(dgvLot.Rows(i).Cells(COND_CELL).Value.ToString) Then 'UPD MIAO 2019/1/7
                dgvLot.Rows(i).Cells(COND_CELL).Value = HYPHEN
            End If
        Next

        ' 共通項目
        Dim item1 As String = String.Empty
        Dim item2 As String = String.Empty
        Dim item3 As String = String.Empty
        For Each drJyoken In dtJyokenData.Rows
            If drJyoken("KOTEI").Equals(GC_LOTINFO) Then
                If drJyoken("KOMOKUNAME").Equals(GC_KIND_NM) Then
                    lblkindNm.Text = drJyoken("KOMOKUDATA")
                ElseIf drJyoken("KOMOKUNAME").Equals(GC_PB_LAYOUT) Then
                    lblPbLayout.Text = drJyoken("KOMOKUDATA")
                ElseIf drJyoken("KOMOKUNAME").Equals(GC_SHAPE) Then
                    lblShape.Text = drJyoken("KOMOKUDATA")
                End If
            End If
        Next
        markchart = getMarkChart()

    End Sub

    Private Sub getPreDetail(ByVal lotNo As String)
        Dim Pre_Proc_Table As String = ""

        '前工程のテーブルを取得　maruyama@tmc 2017/7/26
        Dim dtPreProc = m_cData.GetPreProcCode(IcTag.szLotNo, lblProcessCD.Text) 'UPD 苗 2018/1/13 
        If dtPreProc.Rows.Count > 0 Then
            Pre_Proc_Table = DBNullTOblank(dtPreProc.Rows(0)("PROCTABLE")) 'UPD MIAO 2018/11/6
        End If

        If Not String.IsNullOrEmpty(Pre_Proc_Table) Then
            dtPreDetailData = m_cEquipMat.GetPreDetailData(IcTag.szLotNo, TOTAL, Pre_Proc_Table) 'UPD 苗 2018/1/13 
            ' 前工程のラックNoをHashTableに格納
            htRackNo = New Hashtable
            rackNoCnt = 0
            If dtPreDetailData.Rows.Count > 0 Then
                For i = 0 To dtPreDetailData.Rows.Count - 1
                    'UPD 苗 2018/1/5 BEGIN
                    If DBNullTOblank(dtPreDetailData.Rows(i)("MNF_CND_TAG")).Equals(GC_RACK_NO) Then 'UPD MIAO 2018/11/6
                        If Not String.IsNullOrEmpty(DBNullTOblank(dtPreDetailData.Rows(i)("ACTUAL_MODEL"))) _
                            AndAlso Not DELETE_RACK_NO.Equals(DBNullTOblank(dtPreDetailData.Rows(i)("ACTUAL_MODEL"))) Then 'UPD MIAO 2018/11/6
                            ' ラックNoが空でない場合かつ,'9999999999'以外の場合のみ，HashTableに積む
                            rackNoCnt += 1
                            With htRackNo
                                .Add(rackNoCnt - 1, DBNullTOblank(dtPreDetailData.Rows(i)("ACTUAL_MODEL"))) 'UPD MIAO 2018/11/6
                            End With
                        End If
                        'ElseIf dtPreDetailData.Rows(i)("MNF_CND_TAG").Equals(GC_COMP_MS_RACK_NO) Then
                        '    If Not String.IsNullOrEmpty(dtPreDetailData.Rows(i)("ACTUAL_MODEL")) _
                        '    AndAlso Not DELETE_RACK_NO.Equals(dtPreDetailData.Rows(i)("ACTUAL_MODEL")) Then
                        '        ' ラックNoが空でない場合かつ,'9999999999'以外の場合のみ，HashTableに積む
                        '        rackNoCnt += 1
                        '        With htRackNo
                        '            .Add(rackNoCnt - 1, dtPreDetailData.Rows(i)("ACTUAL_MODEL"))
                        '        End With
                        '    End If
                    End If
                    ''UPD 苗 2018/1/5 END
                Next
            End If
        Else
            dtPreDetailData = New DataTable
        End If

    End Sub

    ' 現物型式表示
    Protected Sub setDetailData()
        dtDetailData = New DataTable

        If m_szTable.ToUpper.Equals("L_SF_WORK_RSLT_A42") Then Exit Sub
        If IcTag.Status = TagProcessStatus.Ready Then
            ' 着工前の場合
            dtDetailData = m_cEquipMat.GetDetailResult(IcTag.szLotNo, m_szProc, HYPHEN, m_szTable) '苗 GROUP ID 修正 2018/1/12　
        ElseIf IcTag.Status = TagProcessStatus.Processing Then
            ' 着工中の場合
            dtDetailData = m_cEquipMat.GetDetailResult(IcTag.szLotNo, m_szProc, BEGIN, m_szTable) '苗 GROUP ID 修正 2018/1/12
        Else
            ' 製造完成の場合
            dtDetailData = m_cEquipMat.GetDetailResult(IcTag.szLotNo, m_szProc, COMPLETE, m_szTable) '苗 GROUP ID 修正 2018/1/12
        End If

        setResultData()

    End Sub

    ' GridViewに現物型式を表示
    Private Sub setResultData()
        Dim i As Integer = 0

        ' GridViewの項目数分ループ
        For i = 0 To dtRowsCount - 1
            If dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_CONFIRM) _
                AndAlso Not String.IsNullOrEmpty(dgvLot.Rows(i).Cells(COND_CELL).Value) _
                    AndAlso dgvLot.Rows(i).Cells(COND_CELL).Value.Equals(HYPHEN) Then
                ' 製造条件が見つからない場合かつ確認項目の場合は「確認不要」を表示
                dgvLot.Rows(i).Cells(RESULT_CELL).Value = getMsgStr("MSG00055")
                dgvLot.Rows(i).Cells(RESULT_CELL).Style.BackColor = Color.Empty
                dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value = NOTCHECKED
                dgvLot.Rows(i).Cells(CHECK_CELL).Value = CHECK_THROUGH
                If i = 0 Then
                    ' 1行目が「確認不要」の場合，確認ボタンを押下不可にする
                    btnActivate(dgvLot.Rows(i).Cells(KOMOKU_CELL).Value)
                End If
            Else
                ' 例外検出を抑制
                dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value = 0
            End If

            ' 明細項目数分ループ
            For Each drDetail In dtDetailData.Rows
                ' GridViewの製造条件TAGと明細テーブルの項目名を比較
                If dgvLot.Rows(i).Cells(CONDTAG_CELL).Value.Equals(drDetail("MNF_CND_TAG")) Then
                    If dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_CONFIRM) Then
                        ' 確認の場合
                        If drDetail("ACTUAL_MODEL").Equals(CHECKED) Then
                            dgvLot.Rows(i).Cells(RESULT_CELL).Value = getMsgStr("MSG00054")
                            dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value = CHECKED
                        ElseIf drDetail("ACTUAL_MODEL").Equals(NOTCHECKED) Then
                            dgvLot.Rows(i).Cells(RESULT_CELL).Value = getMsgStr("MSG00055")
                            dgvLot.Rows(i).Cells(CHECKRESULT_CELL).Value = NOTCHECKED
                        End If
                    ElseIf dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_ZUKEI) Then
                        ' 図形の場合，製造条件表示で表示完了しているため何もしない
                    Else
                        ' 一致した場合，GridViewに現物型式を表示する
                        dgvLot.Rows(i).Cells(RESULT_CELL).Value = drDetail("ACTUAL_MODEL")
                    End If
                    Continue For
                End If
            Next
        Next

        ' 全項目確認不要の場合にcheckFlgを「1」にする
        checkAllCell()

    End Sub
    Overridable Sub setTextDataEmpty(textData As TextBox)
        textData.Text = String.Empty

    End Sub
    ' ラックNo用バーコードクリック
    Protected Sub btnRackNo_Click(ByVal sender As Object, ByVal e As EventArgs)


        rackCount = 0 'ADD MIAO 2018/9/26 

        Dim btn As Button = CType(sender, Button)

        ' 画面の初期化
        For i = 2 To 6 ' ラックNoの入力は02～06。
            Dim textData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}{1:00}", btn.Tag.ToString, i), False)(0)
            Dim labelData As Label = textData.Parent.Controls.Find(String.Format("lbl{0}{1:00}", textData.Tag.ToString, i), False)(0)
            setTextDataEmpty(textData)
            textData.BackColor = TENKEY_INIT_COLOR
            labelData.BackColor = TENKEY_INIT_COLOR
        Next

        ' 入力フォーカスの設定
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}02", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = Color.Cyan
        lblData.BackColor = Color.Cyan
    End Sub

    ' ラックNo用LostFocus
    Protected Sub txtRackNo_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
        Dim txtRack1 As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}02", txtData.Tag.ToString), False)(0)

        If String.IsNullOrEmpty(txtData.Text) AndAlso Not txtRack1.BackColor = ERROR_INIT_COLOR Then

            txtData.BackColor = BARCODE_INIT_COLOR
            lblSys.BackColor = BARCODE_INIT_COLOR

        End If
        txtData.Enabled = False
    End Sub

    ' ラックNoDB工程用KeyPress
    Protected Sub txtRackNoDB_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then

            Dim txtData As TextBox = CType(sender, TextBox)
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
            Dim lblMsg As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)

            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                ' LostFocusがラックNo1の場合，空白チェックを行う
                If String.IsNullOrEmpty(txtData.Text) Then
                    txtData.BackColor = ERROR_INIT_COLOR
                    lblSys.BackColor = ERROR_INIT_COLOR
                    '>> 2018/2/22 佐川 ラックNo入力動作を統一
                    'txtData.Enabled = False
                    MsgBox(getMsgStr("MSG00020", lblMsg.Text))
                    txtData.Focus()
                    txtData.SelectAll()
                    '>> 2018/2/22 佐川 ラックNo入力動作を統一
                    Exit Sub
                End If
            End If

            ' 空白じゃない場合，重複チェックを行う
            If Not String.IsNullOrEmpty(txtData.Text) Then
                If Not chkRackNoDB(txtData, lblSys) Then
                    'ADD 苗　2018/1/27 BEGIN
                    txtData.Enabled = True
                    txtData.Focus()
                    txtData.SelectAll()

                    e.Handled = True
                    'ADD 苗　2018/1/27 END
                    Exit Sub
                End If
            End If

            '>> 2018/2/23 佐川 RSB確認結果一覧No62
            Dim targetText As TextBox = txtData.Parent.Controls.Find("txt0903", False)(0)
            If txtData.Text.Equals(targetText.Text) Then
                MsgBox(getMsgStr("MSG10018", txtData.Text))
                txtData.Enabled = True
                txtData.Focus()
                txtData.SelectAll()
                e.Handled = True
                txtData.BackColor = ERROR_INIT_COLOR
                lblSys.BackColor = ERROR_INIT_COLOR
                Exit Sub
            End If
            '<< 2018/2/23 佐川 RSB確認結果一覧No62

            '>>20180313 大賀 搬送容器桁数チェックを共通化
            ' ラックNoの桁数チェック
            If Not isCheckCaseLength(txtData, RACK_CASE_NO_LENGTH, lblSys) Then
                e.Handled = True
                Exit Sub
            End If
            '<<20180313 大賀 搬送容器桁数チェックを共通化

            ''ADD 苗　2018/1/27 BEGIN（A41，S42，A51のラックNo.の６桁のチェック）
            'If m_RackWidthCheck And txtData.Text.Length <> RACK_CASE_NO_LENGTH Then 'UPD 苗 2018/2/28 6桁じゃない場合、エラー
            '    MsgBox(getMsgStr("MSG00001", lblMsg.Text))
            '    txtData.Enabled = True
            '    txtData.Focus()
            '    txtData.SelectAll()
            '    '>> 2018/2/23 佐川 エラー時に赤色に変更
            '    txtData.BackColor = ERROR_INIT_COLOR
            '    lblSys.BackColor = ERROR_INIT_COLOR
            '    '<< 2018/2/23 佐川 エラー時に赤色に変更
            '    e.Handled = True
            '    Exit Sub
            'End If
            ''ADD 苗　2018/1/27 END

            For i = 2 To 6
                If txtData.Name = String.Format("txt{0}0{1}", txtData.Tag.ToString, i) Then
                    lblSys = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i), False)(0)

                    txtData.BackColor = ENTERED_INIT_COLOR
                    lblSys.BackColor = ENTERED_INIT_COLOR
                    txtData.Enabled = False

                    '5列目以下だったらフォーカスを移す
                    If i < 6 Then
                        Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)
                        Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)

                        nextTxtData.Enabled = True
                        nextTxtData.Focus()
                        nextTxtData.SelectAll()
                        nextTxtData.BackColor = Color.Cyan
                        nextLbl.BackColor = Color.Cyan
                    End If
                End If
            Next
        End If
    End Sub

    ' ラックNo用KeyPress
    Protected Sub txtRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox)
            Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
            Dim lblMsg As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
            Dim rackChkFlg As Boolean = False
            Dim inputRackNoArray() = {"", "", "", ""}

            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                ' LostFocusがラックNo1の場合，空白チェックを行う
                If String.IsNullOrEmpty(txtData.Text) Then
                    txtData.BackColor = ERROR_INIT_COLOR
                    lblSys.BackColor = ERROR_INIT_COLOR
                    txtData.Enabled = False
                    MsgBox(getMsgStr("MSG00020", (lblMsg.Text).Replace(vbCrLf, "")))
                    Exit Sub
                End If
            End If

            ' 着工時のみ前工程のラックNoと比較する
            If IcTag.Status = TagProcessStatus.Ready Then
                ' ラックNoを前工程と比較
                For i = 0 To rackNoCnt - 1
                    inputRackNoArray(i) = txtData.Text
                    'ラックNoが削除ラックNoの場合、重複チェックを行わない。
                    If DELETE_RACK_NO.Equals(txtData.Text) Then
                        rackChkFlg = True
                        Exit For
                    End If
                    ' 前工程のラックNoと一致する場合
                    If htRackNo(i).Equals(txtData.Text) Then
                        ' 重複チェックを行う
                        rackChkFlg = chkRackNo(txtData, lblSys)
                        If Not rackChkFlg Then
                            ' 重複していたら抜ける
                            Exit Sub
                        End If

                        rackChkFlg = True
                        Exit For
                    End If
                Next

                ' 前工程のどのラックNoとも一致しない場合
                If Not rackChkFlg Then
                    MsgBox(getMsgStr("MSG00052", lblMsg.Text))
                    txtData.BackColor = ERROR_INIT_COLOR
                    lblSys.BackColor = ERROR_INIT_COLOR
                    txtData.Enabled = False
                    m_iScore(CInt(txtData.Tag) - 1) = 0
                    Exit Sub
                End If
            Else
                ' 空白じゃない場合，重複チェックを行う
                If Not String.IsNullOrEmpty(txtData.Text) Then
                    If Not chkRackNo(txtData, lblSys) Then
                        Exit Sub
                    End If
                End If
            End If


            ' 着工時のみ前工程のラックNoと比較する
            If IcTag.Status = TagProcessStatus.Ready Then
                ' ラック数が前工程と一致した場合 かつ ラックNoが全削除でない場合
                If htRackNo.Count = CInt(txtData.Name.ToString.Substring(5, 2)) - 1 AndAlso chkAllDelRackNo(inputRackNoArray) Then
                    txtData.BackColor = ENTERED_INIT_COLOR
                    lblSys.BackColor = ENTERED_INIT_COLOR
                    txtData.Enabled = False
                    m_iScore(CInt(txtData.Tag) - 1) = 1
                    CheckCollScore()
                    Exit Sub
                Else
                    ' ラック数が前工程と一致しない場合 または ラックNoが全削除の場合
                    m_iScore(CInt(txtData.Tag) - 1) = 0
                End If
            End If

            For i = 2 To 5
                If txtData.Name = String.Format("txt{0}0{1}", txtData.Tag.ToString, i) Then
                    lblSys = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i), False)(0)

                    txtData.BackColor = ENTERED_INIT_COLOR
                    lblSys.BackColor = ENTERED_INIT_COLOR
                    txtData.Enabled = False

                    '4列目以下だったらフォーカスを移す
                    If i < 5 Then
                        Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)
                        Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)

                        nextTxtData.Enabled = True
                        nextTxtData.Focus()
                        nextTxtData.SelectAll()
                        nextTxtData.BackColor = Color.Cyan
                        nextLbl.BackColor = Color.Cyan
                    End If
                End If
            Next

        End If
    End Sub

    Protected Function chkRackNo(ByVal txtData As TextBox, ByVal lblSys As Label) As Boolean
        'ラックNoが削除ラックNoの場合、重複チェックを行わない。
        If DELETE_RACK_NO.Equals(txtData.Text) Then
            Return True
        End If
        Dim lblRack As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        ' 重複チェックを行う
        For j = 2 To 5
            Dim txtDataCheck As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, j), False)(0)
            ' LostFocusしたラックNo以外と比較
            If Not txtData.Name.Equals(txtDataCheck.Name) Then
                ' 入力されたラックNoが同じ値の場合
                If txtData.Text.Equals(txtDataCheck.Text) Then
                    txtData.BackColor = ERROR_INIT_COLOR
                    lblSys.BackColor = ERROR_INIT_COLOR
                    txtData.Enabled = False
                    MsgBox(getMsgStr("MSG00064", (lblRack.Text).Replace(vbCrLf, "")))
                    m_iScore(CInt(txtData.Tag) - 1) = 0
                    Return False
                End If
            End If
        Next
        Return True
    End Function

    Protected Function chkAllDelRackNo(ByRef rackNo() As String) As Boolean
        'ラックNoがすべて削除ラックNoの場合、エラーとする。
        Dim delRackNum As Integer = 0
        Dim rackNoNum As Integer = 0
        For i = 1 To 4
            If rackNo(i - 1).Length > 0 Then
                rackNoNum += 1
                If DELETE_RACK_NO.Equals(rackNo(i - 1)) Then
                    delRackNum += 1
                End If
            End If
        Next
        If delRackNum = rackNoNum Then
            MsgBox(getMsgStr("MSG00137"))
            Return False
        End If

        Return True
    End Function

    Protected Function chkRackNoDB(ByVal txtData As TextBox, ByVal lblSys As Label) As Boolean
        Dim lblRack As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        ' 重複チェックを行う
        For j = 2 To 5
            Dim txtDataCheck As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, j), False)(0)
            ' LostFocusしたラックNo以外と比較
            If Not txtData.Name.Equals(txtDataCheck.Name) Then
                ' 入力されたラックNoが同じ値の場合
                If txtData.Text.Equals(txtDataCheck.Text) Then
                    txtData.BackColor = ERROR_INIT_COLOR
                    lblSys.BackColor = ERROR_INIT_COLOR
                    txtData.Enabled = False
                    MsgBox(getMsgStr("MSG00064", lblRack.Text))
                    Return False
                End If
            End If
        Next
        Return True
    End Function

    Private Function lotEndCheck() As Boolean
        For i = 0 To dtRowsCount - 1
            If dtGridViewMaster.Rows(i)("COMPLETE_ACTIVE_FLG").Equals(ACTIVE) Then
                If Not checkCell(i) Then
                    PutLog(Me.ToString, "lotEndCheck", "err:checkCell")
                    Return False
                End If
                If dtGridViewMaster.Rows(i)("INPUT_METHOD").Equals(METHOD_SELECT) AndAlso
                    dtGridViewMaster.Rows(i)("SELECT_WINDOW").Equals(OK_NG) AndAlso
                    dgvLot.Rows(i).Cells(RESULT_CELL).Value.Equals(NG) Then
                    ' 選択ボタン"OK/NG"の場合，かつ値が"NG"の場合はエラーとする
                    PutLog(Me.ToString, "lotEndCheck", getMsgStr("MSG00092", dgvLot.Rows(i).Cells(KOMOKU_CELL).Value))
                    MsgBox(getMsgStr("MSG00092", dgvLot.Rows(i).Cells(KOMOKU_CELL).Value))
                    Return False
                End If
            End If
        Next

        Return True
    End Function

    Protected Sub getHeadData()
        Dim type As String

        If IcTag.Status = TagProcessStatus.Ready Then
            'type = ""
            Exit Sub
        ElseIf IcTag.Status = TagProcessStatus.Processing Then
            type = BEGIN
        Else
            type = COMPLETE
        End If
        m_dtMat = m_cEquipMat.GetResultHead(lotNo, type, lblProcessCD.Text)
    End Sub
    ' 2017/05/12 蘇州対応 追加

    '2017/06/02 蘇州対応　テンキー対応 maruyama
    Protected Sub GetControlItem(ByVal Ctrl As Control, ByVal sender As System.Object)
        For Each CtrlItem As Control In Ctrl.Controls
            If TypeOf CtrlItem Is TenKey Then
                CtrlItem.Dispose()
            End If
            If TypeOf CtrlItem Is TenKey Then
                CtrlItem.Dispose()
            End If
            If CtrlItem IsNot sender Then
                If TypeOf CtrlItem Is TenKeyLabel Then
                    CType(CtrlItem, TenKeyLabel).EndEdit()

                ElseIf TypeOf CtrlItem Is Label Then
                    If CtrlItem.BackColor = Color.Cyan Then
                        CtrlItem.BackColor = TENKEY_INIT_COLOR
                    End If
                End If
            End If
            If CtrlItem.Controls.Count > 0 Then
                GetControlItem(CtrlItem, sender)
            End If
        Next
    End Sub

    '2017/06/15 テンキー対応　maruyama
    Private Sub TenkeyText_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles TenkeyText.KeyPress
        If e.KeyChar = vbCr Then
            Call btnE_Click(sender, e)
        End If
    End Sub

    Private Sub TenkeyText_Grid_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles TenkeyText_Grid.KeyPress
        If e.KeyChar = vbCr Then
            Call btnE_Click_Grid(sender, e)
        End If
    End Sub

    Private Sub btnDiffLot_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDiffLot.Click
        txtDiffLot.Enabled = True
        txtDiffLot.Focus()
        txtDiffLot.SelectAll()
    End Sub

    Protected Sub txtDiffLot_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles txtDiffLot.KeyPress
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            PutLog(btnOptNoStt.ToString, txtOptNoStt.Text, "組立ロットＮｏ．")

            Dim txtDiff As TextBox = CType(sender, TextBox)
            txtDiff.BackColor = Color.Yellow
            txtDiff.Enabled = False

            If txtDiffLot.Text.Length > 0 Then

                txtLotNo.Text = m_cData.GetDiffLotData(txtDiffLot.Text)
                If txtLotNo.Text.Length > 0 Then
                    Call btnTag_Click(sender, e)
                Else
                    MsgBox(getMsgStr("MSG10011", txtDiffLot.Text))
                End If

                chkUserEndTime() 'ADD MIAO 2019/10/1

            End If
        End If
    End Sub

    'ウェハラックNoのバーコードボタン押下時の処理
    Protected Overridable Sub WaferRacNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}03", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)

        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = FOCUS_INIT_COLOR
        lblData.BackColor = FOCUS_INIT_COLOR
    End Sub

    'ウェハラックNoのテキストLostFocus時の処理
    Protected Overridable Sub WaferRackTxtData_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)
        Dim lblCondData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        Dim lblItem As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        Dim checkFlag As Boolean = True
        Dim idx As Integer = CInt(lblData.Name.Substring(3, 2)) - 1
        Dim title As String = lblItem.Text.Replace(Environment.NewLine, "")

        '空白チェック
        If Not checkBlank(txtData.Text, title) Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        'ＭＷチェック
        If Not checkType(txtData.Text, title, lblData.Tag) Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        If IcTag.Status = TagProcessStatus.Ready Then
            '前工程一致チェック
            If lblCondData.Text <> HYPHEN Then
                checkFlag = checkMatch(lblCondData.Text, txtData.Text, title, lblCondData.Name)
            End If
        Else
            '着工時一致チェック
            If txtData.Text <> lblCondData.Text Then
                MsgBox(getMsgStr("MSG00089", title))
                checkFlag = False
            End If
        End If

        If Not checkFlag Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        '照合結果の更新
        lblData.BackColor = ENTERED_INIT_COLOR
        txtData.BackColor = ENTERED_INIT_COLOR
        If IcTag.Status = TagProcessStatus.Ready Then
            m_iScore(idx) = 1
            CheckCollScore()
        End If

    End Sub

    '2017/06/21 endo
    '一貫ラックNoのバーコードボタン押下時の処理
    Protected Overridable Sub ConsRacNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}02", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)

        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = FOCUS_INIT_COLOR
        lblData.BackColor = FOCUS_INIT_COLOR
    End Sub

    '一貫ラックNoのテキストLostFocus時の処理
    Protected Overridable Sub ConsRackTxtData_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        Dim lblItem As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        Dim checkFlag As Boolean
        Dim idx As Integer

        '空白チェック
        checkFlag = checkBlank(txtData.Text, lblItem.Text)

        '背景色の設定
        checkColor(sender, checkFlag, lblData.Name)

        '照合結果の更新
        If IcTag.Status = TagProcessStatus.Ready Then

            idx = CInt(lblData.Name.Substring(3, 2)) - 1

            If checkFlag = True Then
                m_iScore(idx) = 1
                CheckCollScore()

            Else
                m_iScore(idx) = 0

            End If
        End If

    End Sub

    '一貫ラックNoのテキストLostFocus時の処理（前工程一貫ラックNoとの比較あり）
    Protected Overridable Sub ConsRackTxtData_NoChk_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        Dim lblItem As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        Dim checkFlag As Boolean
        Dim idx As Integer = CInt(lblData.Name.Substring(3, 2)) - 1
        Dim preConsRackNo As String = String.Empty

        For Each dr In dtPreDetailData.Rows
            If dr("MNF_CND_TAG").Equals(GC_CONS_RACK_NO) Then
                '前工程一貫ラックNo
                preConsRackNo = dr("ACTUAL_MODEL")
                Exit For
            End If
        Next

        '空白チェック
        checkFlag = checkBlank(txtData.Text, lblItem.Text)
        If Not checkFlag Then
            checkColor(sender, checkFlag, lblData.Name)
            m_iScore(idx) = 0
            Exit Sub
        End If

        checkFlag = checkMatch(preConsRackNo, txtData.Text, lblItem.Text, lblData.Name)
        If Not checkFlag Then
            checkColor(sender, checkFlag, lblData.Name)
            m_iScore(idx) = 0
        Else
            checkColor(sender, checkFlag, lblData.Name)
            m_iScore(idx) = 1
            CheckCollScore()
        End If
    End Sub

    '情報部の確認ボタン処理
    Protected Sub btnJohoConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        btnConfirm = CType(sender, Button)
        lblConfirm = btnConfirm.Parent.Controls.Find(String.Format("lbl{0}03", btnConfirm.Tag), False)(0)
        m_DelayType = DelayType.Confirm
        Dim idx As Integer
        idx = CInt(lblConfirm.Tag) - 1

        If String.IsNullOrEmpty(lblConfirm.Text) Then
            lblConfirm.Text = getMsgStr("MSG00054")
            lblConfirm.BackColor = ENTERED_INIT_COLOR
            m_iScore(idx) = 1
            CheckCollScore()
        ElseIf lblConfirm.Text.Equals(getMsgStr("MSG00054")) Then
            lblConfirm.Text = String.Empty
            lblConfirm.BackColor = NORMAL_INIT_COLOR
            m_iScore(idx) = 0
            Exit Sub
        Else
            Exit Sub
        End If
    End Sub

    '不良率計算処理
    Protected Sub FailureRateCalc(ByVal failureRateLabel As Label, ByVal failureRP As Label, ByVal pControlLabel As Label)
        '>>20171016 兪
        If Not m_fProcessCheck Then
            failureRateLabel.Text = "0"
            lblInputCnt.Text = "0"
            Exit Sub
        End If
        '<<20171016 兪
        Dim FailedCnt As Double = Integer.Parse(lblFailedCnt.Text)
        Dim InputCnt As Double = Integer.Parse(lblInputCnt.Text)

        Dim lblData As Label = pControlLabel.Parent.Controls.Find(String.Format("lbl{0}00", failureRP.Name.ToString.Substring(3, 2)), False)(0)

        If Not FailedCnt = 0 Then
            failureRateLabel.Text = (Math.Round(FailedCnt / InputCnt, 3, MidpointRounding.AwayFromZero) * 100).ToString
        Else
            failureRateLabel.Text = "0"
        End If

        Dim failureRate_Double As Double = 0

        If Not Double.TryParse(failureRateLabel.Text, failureRate_Double) Then
            MsgBox(getMsgStr("MSG00011", lblData.Text))
            pControlLabel.Text = NG
            pControlLabel.BackColor = ERROR_INIT_COLOR
            Return
        End If

        Dim failureRP_Double As Double = 0
        If Not String.IsNullOrEmpty(failureRP.Text.Trim) Then
            If Not Double.TryParse(failureRP.Text.Replace("%", ""), failureRP_Double) Then
                MsgBox(getMsgStr("MSG00011", lblData.Text))
                pControlLabel.Text = NG
                pControlLabel.BackColor = ERROR_INIT_COLOR
                Return
            End If
        End If
        ' P管理判定（不良率 < 不良率管理値なら空白 それ以外はNG）
        If failureRate_Double < failureRP_Double Then
            pControlLabel.Text = String.Empty
            pControlLabel.BackColor = NORMAL_INIT_COLOR
        Else
            pControlLabel.Text = NG
            pControlLabel.BackColor = ERROR_INIT_COLOR
        End If
    End Sub

    'INIファイルの値によって拡散ロットNoか組立ロットNoか判定する
    Public Function SelectLotNo() As String
        If inputLotType = INPUTLOTTYPE_DIFF Then
            '>>2018/2/22 大賀 拡散ロットの場合はGroupKeyNoではなくIcTagのロットNoを使う
            'Return lblDiffLotNo.Text
            Return IcTag.szLotNo
            '<<2018/2/22 大賀 拡散ロットの場合はGroupKeyNoではなくIcTagのロットNoを使う
        Else
            Return lblLotNo.Text
        End If
    End Function

    '前工程のロットタイプによって拡散ロットか組立ロットか判定する
    Public Function SelectPreLotNo() As String
        If m_szPreProcLotType = INPUTLOTTYPE_DIFF Then
            Return lblDiffLotNo.Text
        Else
            Return lblLotNo.Text
        End If
    End Function

    Protected Overridable Sub enableBtn()

    End Sub

    Protected Overridable Function checkCntCheck() As Boolean
        Return True
    End Function

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim frmMarkChart As New ShowSelectForm
        With frmMarkChart
            .lblText.Text = markchart
            '>>20180122 佐川
            '            .lblText.AutoSize = True
            '<<20180122 佐川
            .lblText.BackColor = FOCUS_INIT_COLOR
            .lblText.TextAlign = ContentAlignment.TopLeft
            '<<20180122 佐川
            .lblText2.Text = markchartsize
            '>>20180122 佐川
            .Button1.Visible = False
            .Button2.Visible = False
            .Button3.Visible = False
            .Button4.Text = "OK"
            .Button4.DialogResult = DialogResult.OK
            .Button4.Visible = True
            .StartPosition = FormStartPosition.CenterParent
            .ShowDialog()
        End With
    End Sub

    Private Function getMarkChart() As String
        getMarkChart = String.Empty

        '>>20180122 佐川
        'Dim GetDetailProcCd_MARK = GetIniFile("GetDetailProcCode", "MARK", "", g_szInitFileName)
        'If String.IsNullOrEmpty(GetDetailProcCd_MARK) Then
        '    Return getMarkChart
        'End If
        Dim dtCondMark = m_cData.GetJyokenData(IcTag.szLotNo, lblProcessCD.Text)
        'UPD 苗 2018/2/27 BEGIN
        If dtCondMark.Rows.Count = 0 Then
            getMsgStr("MSG00009", Button1.Text)
            Return getMarkChart
        End If
        'UPD 苗 2018/2/27 END
        '<<20180122 佐川
        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = IcTag.szLotNo
        Dim clientStr As String = GetBsiteClientString()
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        Dim weekcode As String = String.Empty
        If viewLotServiceInfo.LotInf IsNot Nothing AndAlso
                viewLotServiceInfo.LotInf.WeeklyCode IsNot Nothing AndAlso
                viewLotServiceInfo.LotInf.WeeklyCode.Length > 0 Then
            weekcode = viewLotServiceInfo.LotInf.WeeklyCode
        End If
        Dim reg As New System.Text.RegularExpressions.Regex("[" + getMsgStr("MSG00139") + "\x00]+")
        '>>20180122 佐川
        Dim loopCount As Double = 0
        For Each dr As DataRow In dtCondMark.Select("KOMOKUNAME LIKE '" + MARK_DATA + "%' AND NOT KOMOKUNAME LIKE '%" + MARK_SIZE + "'  AND NOT KOMOKUNAME LIKE '%DETAIL' ", "KOMOKUNAME ASC") 'UPD 苗 2018/2/3
            If dr("KOMOKUNAME").Equals(MARK_DATA) Then
                Continue For
            End If

            If Not loopCount = 0 Then
                getMarkChart += vbNewLine
            End If

            If weekcode.Length > 0 Then
                getMarkChart += reg.Replace(dr("KOMOKUDATA").ToString, weekcode) + Space(3)
            Else
                getMarkChart += dr("KOMOKUDATA").ToString + Space(3)
            End If
            loopCount += 1
            '<<20180122 佐川
        Next
        If Not String.IsNullOrEmpty(getMarkChart) Then
            getMarkChart += vbNewLine
        End If

        '>>20180122 佐川
        loopCount = 0
        markchartsize = String.Empty
        For Each dr As DataRow In dtCondMark.Select("KOMOKUNAME LIKE '%" + MARK_SIZE + "' ", "KOMOKUNAME ASC")

            If Not loopCount = 0 Then
                markchartsize += vbNewLine
            End If

            If weekcode.Length > 0 Then
                markchartsize += reg.Replace(dr("KOMOKUDATA").ToString, weekcode)
            Else
                markchartsize += dr("KOMOKUDATA").ToString
            End If
            loopCount += 1
        Next
        If Not String.IsNullOrEmpty(markchartsize) Then
            markchartsize += vbNewLine
        End If
        '<<20180122 佐川

    End Function

    '一貫ラックNoの有効チェック
    Protected Function checkRackArea(shape As String, consRackNo As String) As Boolean
        '製品外形を比較用に成形
        Dim index As Integer = shape.LastIndexOf("-"c)
        Dim customShape As String = shape.Remove(index)

        'ラックNoを比較用に成形
        Dim customConsRackNo As Integer = 0
        If Not Integer.TryParse(consRackNo.Substring(1), customConsRackNo) Then
            Return False
        End If

        ' insitetestDB接続
        ConnectItinfraDB()

        Dim result As DataTable = m_cItinfra.GetRackArea(customShape)

        ' insitetestDB切断
        itinfraDBacs.Disconnect()

        If result.Rows.Count > 0 Then
            Dim lowerLimit As Integer = Integer.Parse(result.Rows(0)("LowerLimit"))
            Dim UpperLimit As Integer = Integer.Parse(result.Rows(0)("UpperLimit"))
            If lowerLimit <= customConsRackNo And UpperLimit >= customConsRackNo Then
                Return True
            End If
        End If

        Return False
    End Function

    'ペーストDB接続処理
    Private Sub ConnectItinfraDB()
        With itinfra_Server
            g_iDBconnResult = itinfraDBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver, .iPORT) 'ADD MIAO 2018/10/19
            If 1 <> g_iDBconnResult Then
                .szDrive = CStr(IIf("SQL Server" = .szDrive, "SQL Server", "SQL Server"))
                g_iDBconnResult = itinfraDBacs.Connect(.szDrive, .szIPadr, .szDsn, .szDbn, .szUid, .szPas, .iOver, .iPORT) 'ADD MIAO 2018/10/19
            End If
        End With
    End Sub

    '>>20171010 兪
    '>>2018/02/20 安部 swapTimer削除
    'Protected WithEvents swapTimer As New Timer
    '<<2018/02/20 安部 swapTimer削除

    Private Const CHK_SWAP_INTERVAL As Integer = 100
    Private m_fIsInSwap As Boolean = False
    '>>2018/02/20 安部 swapTimer削除
    'Private Sub swapTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles swapTimer.Tick
    '    Static Dim iSwapTimer As Integer = 0

    '    swapTimer.Interval = 1000

    '    If m_ProcessStatus = ProcessStatus.Ready OrElse
    '       m_ProcessStatus = ProcessStatus.TagSet Then
    '        If m_fIsInSwap Then
    '            Exit Sub
    '        End If

    '        '切替指示チェック
    '        If iSwapTimer > CHK_SWAP_INTERVAL Then
    '            iSwapTimer = 0
    '            CheckSwapStatus()
    '        Else
    '            iSwapTimer += 1
    '        End If
    '    End If

    'End Sub
    '>>2018/02/20 安部 swapTimer削除

    '>>2018/02/20 安部 swapTimer削除
    'Private Sub CheckSwapStatus()
    '    swapTimer.Stop()
    '    Dim swap As SwapStatus = CType(clsDbSEquip.GetSwapStatus(g_EQUIP_NO), SwapStatus) 'UPD 苗 2018/1/19 装置No.の対応
    '    If swap = SwapStatus.TO_SWAP Then
    '        m_fIsInSwap = True
    '        Dim szMsg As String = "新しい切替指示があります。切替画面を開いてください。" & vbCrLf &
    '            "有新的品种切换指示，请打开品种切换画面。"
    '        MsgBox(szMsg, MsgBoxStyle.Information)
    '        btnStart.BackColor = Color.Yellow
    '        btnStart.Text = "切替"
    '    Else
    '        swapTimer.Start()
    '    End If
    'End Sub
    '<<2018/02/20 安部 swapTimer削除

    '<<20171010 兪

    '>>20171012 兪
    ''' <summary>
    ''' ロット情報の同期
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub SyncLotInfo()
        If Not String.IsNullOrEmpty(IcTag.szLotNo) Then

            Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()

            '>>20171012_1 兪
            'Select Case inputLotType
            '    Case frmStartCompleteBase.INPUTLOTTYPE_DIFF
            '        param.Name = IcTag.szDifLotNo
            '    Case Else
            '        param.Name = IcTag.szLotNo
            'End Select
            param.Name = IcTag.szLotNo
            '<<20171012_1 兪

            Dim clientStr As String = GetBsiteClientString()
            Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
            If Not IsNothing(viewLotServiceInfo) AndAlso STS_SUCCESS.Equals(viewLotServiceInfo.Header.Status) Then
                With viewLotServiceInfo
                    IcTag.szProcsCD = .LotInf.Operation

                    If .LotInf.InProcess Then
                        If IsBsiteMulti() Then
                            Dim rackStatus = m_cWBRackMng.getEquipIdStatus(IcTag.szLotNo, lblEquipID.Text)
                            If rackStatus <> IcTag.Status Then
                                IcTag.Status = rackStatus
                            End If
                        Else
                            If IcTag.Status = TagProcessStatus.Ready Then
                                IcTag.Status = TagProcessStatus.Processing
                            End If
                        End If
                    Else
                        If IcTag.Status <> TagProcessStatus.Ready Then
                            IcTag.Status = TagProcessStatus.Ready
                        End If
                    End If

                    If .LotInf.Machine.Length > 0 AndAlso .LotInf.Machine(0) <> "" Then
                        IcTag.szEquipID = .LotInf.Machine(0)
                    End If

                    If IsNumeric(.LotInf.Qty) Then
                        IcTag.iInput = CInt(.LotInf.Qty)
                        IcTag.iFinish = CInt(.LotInf.Qty)
                    End If
                    'ADD 苗 2018/2/6 BEGIN
                    If IsNumeric(.LotInf.Qty2) Then
                        IcTag.iFrame = CInt(.LotInf.Qty2)
                        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
                        If wf_write_flag = WRITE_WAFER Then
                            IcTag.waferNum = CInt(.LotInf.Qty2)
                        Else
                            IcTag.iFrame = CInt(.LotInf.Qty2)
                        End If
                        '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
                    End If
                    'ADD 苗 2018/2/6 END
                    If .LotInf.IsOnHold Then
                        IcTag.OnHoldSt = OnHoldStatus.OnHold
                    Else
                        IcTag.OnHoldSt = OnHoldStatus.Normal
                    End If
                End With
                setICtagByFrameInfo()
                m_cLotInfo.SaveTagLotInfo(IcTag, setXinFlg, inputLotType)
                '>>20171202 兪
            Else
                MsgBox("组立Key No在bSite里不存在 或者 连接不上bSite,请联系相关人员。", MsgBoxStyle.Information)
                '<<20171202 兪
            End If
        End If
    End Sub
    ''' <summary>
    ''' 同步bSite数据时，是否把frame Info里的X印数和X印枚数一起更新
    ''' 非frameID时，不更新。
    ''' </summary>
    ''' <returns>1：更新，0:不更新</returns>
    Overridable Function setXinFlg() As Integer 'ADD 2020/08/06
        Return 0
    End Function
    '<<20171012 兪
    Overridable Sub setICtagByFrameInfo()

    End Sub

    Protected Function aftercheckMatch(ByVal lblSys As String, ByVal lblData As String, ByVal lblItem As String, ByVal lblName As String) As Boolean

        ' 製造条件なしの場合は、チェック不要
        If lblName.Substring(5, 2).Equals("03") And Not lblSys.Equals("-") Then
            If Not lblSys.Equals(lblData) Then
                MsgBox(getMsgStr("MSG00021", lblItem))
                Return False
            End If
        End If
        ' 着工時ウェハ枚数入力チェック
        If lblName.Substring(5, 2).Equals("01") Then
            Dim dataNumber As Double = Double.Parse(lblData)
            If dataNumber < 1 Then
                MsgBox(getMsgStr("MSG00048", lblItem))
                Return False
            End If
        End If
        ' 着工時データ一致チェック
        If lblName.Substring(5, 2).Equals("02") Then
            If Not lblSys.Equals(lblData) Then
                MsgBox(getMsgStr("MSG00089", lblItem))
                Return False
            End If
        End If

        Return True
    End Function

    'ウェハケースNoのバーコードボタン押下時の処理
    Protected Overridable Sub WaferCaseNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}03", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)

        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = FOCUS_INIT_COLOR
        lblData.BackColor = FOCUS_INIT_COLOR
    End Sub

    'ウェハケースNoのテキストLostFocus時の処理
    Protected Overridable Sub WaferCaseTxtData_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)
        Dim lblCondData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        Dim lblItem As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)
        Dim checkFlag As Boolean = True
        Dim idx As Integer = CInt(lblData.Name.Substring(3, 2)) - 1
        Dim title As String = lblItem.Text.Replace(Environment.NewLine, "")

        '空白チェック
        If Not checkBlank(txtData.Text, title) Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        'ＭＷチェック
        If Not checkType(txtData.Text, title, lblData.Tag) Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        If IcTag.Status = TagProcessStatus.Ready Then
            '前工程一致チェック
            If lblCondData.Text <> HYPHEN Then
                checkFlag = checkMatch(lblCondData.Text, txtData.Text, title, lblCondData.Name)
            End If
        End If

        If Not checkFlag Then
            txtData.BackColor = ERROR_INIT_COLOR
            lblData.BackColor = ERROR_INIT_COLOR
            If IcTag.Status = TagProcessStatus.Ready Then
                m_iScore(idx) = 0
            End If
            Exit Sub
        End If

        '照合結果の更新
        lblData.BackColor = ENTERED_INIT_COLOR
        txtData.BackColor = ENTERED_INIT_COLOR
        If IcTag.Status = TagProcessStatus.Ready Then
            m_iScore(idx) = 1
            CheckCollScore()
        End If

    End Sub
    'UPD  苗 2018/1/26  フレームID対応：args3を追加
    Public Function Execute_Command(ByVal procCd As String, ByVal execPgTag As String, Optional ByVal args1 As String = "", Optional ByVal args2 As String = "", Optional ByVal args3 As String = "", Optional ByVal args4 As String = "") As String
        Dim proc As New Process()
        Dim ProgName As String
        Dim ProgOpt As String
        Dim ProgExitTime As String
        Dim aryProgName As String() 'ADD 苗 2018/4/2

        '外部起動EXE定義読み出し
        Dim dtDefExec = m_cData.GetDefExec(procCd, execPgTag)
        If dtDefExec.Rows.Count > 0 Then

            'ADD 苗 2018/4/2　BEGIN
            '定義が存在する
            ProgName = dtDefExec.Rows(0)("COMMAND_LINE")
            aryProgName = ProgName.Split(";")
            For i = 0 To aryProgName.Count - 1
                If System.IO.File.Exists(aryProgName(i).ToString) = True Then
                    ProgName = aryProgName(i).ToString
                    Exit For
                End If
            Next
            'ADD 苗 2018/4/2　END

            If IsDBNull(dtDefExec.Rows(0)("COMMAND_OPTION")) Then
                ProgOpt = ""
            Else
                If ProgName = "ATLAS-R_Net_Client.exe" Then
                    If args1 = "" Then args1 = "---"
                End If
                'UPD 苗 2018/1/26  BEGIN フレームID対応
                ProgOpt = dtDefExec.Rows(0)("COMMAND_OPTION")
                If String.IsNullOrEmpty(args1) AndAlso String.IsNullOrEmpty(args2) AndAlso String.IsNullOrEmpty(args3) AndAlso String.IsNullOrEmpty(args4) Then
                    ProgOpt = ProgOpt

                ElseIf Not String.IsNullOrEmpty(args1) AndAlso String.IsNullOrEmpty(args2) AndAlso String.IsNullOrEmpty(args3) AndAlso String.IsNullOrEmpty(args4) Then
                    ProgOpt = String.Format(ProgOpt, args1)
                ElseIf Not String.IsNullOrEmpty(args1) AndAlso Not String.IsNullOrEmpty(args2) AndAlso String.IsNullOrEmpty(args3) AndAlso String.IsNullOrEmpty(args4) Then
                    ProgOpt = String.Format(ProgOpt, args1, args2)
                ElseIf Not String.IsNullOrEmpty(args1) AndAlso Not String.IsNullOrEmpty(args2) AndAlso String.IsNullOrEmpty(args3) AndAlso Not String.IsNullOrEmpty(args4) Then
                    ProgOpt = String.Format(ProgOpt, args1, args2, args3, args4)
                Else
                    ProgOpt = String.Format(ProgOpt, args1, args2, args3, args4)
                End If
                'UPD 苗 2018/1/26  END フレームID対応
            End If
            If System.IO.File.Exists(ProgName) = False Then
                'MessageBox.Show("ERR 外部使用的EXE没有定义。")'DEL 苗 2018/4/2
                MsgBox(getMsgStr("MSG10038")) 'ADD 苗 2018/4/2
                Execute_Command = "-1"
                Exit Function
            End If
            'UPD MIAO 2018/8/22 BEGIN
            Try
                proc = System.Diagnostics.Process.Start(ProgName, ProgOpt)
                If ProgName = "ATLAS-R_Net_Client.exe" Then
                    proc.WaitForExit()
                End If
                ProgExitTime = proc.ExitTime.ToString()

                Execute_Command = proc.ExitCode.ToString()
            Catch ex As Exception

            End Try
            'UPD MIAO 2018/8/22 END
        Else
            '定義が存在しない！
            'エラー
            'MsgBox("ERR 外部起動EXE定義が存在しない")'DEL 苗 2018/4/2
            MsgBox(getMsgStr("MSG10039")) 'ADD 苗 2018/4/2
            Execute_Command = "-1"
        End If

        Execute_Command = "0"

    End Function

    ''' <summary>
    ''' b-Siteに送るClientの値を取得する
    ''' </summary>
    ''' <returns>Client文字列</returns>
    Public Function GetBsiteClientString() As String
        Dim retStr = m_cEquipMat.GetBsiteClientString(lblProcessCD.Text)
        Return retStr
    End Function

    'ADD 苗 2018/1/5 BEGIN（X印枚数＞フレーム数の場合、エラー）
    Protected Overridable Function chkCrossFrame() As Boolean 'UPD 苗 2018/1/13

        'ADD 苗 2018/3/1 BEGIN
        If String.IsNullOrEmpty(lblPcbCnt.Text) = False AndAlso CInt(lblPcbCnt.Text) < 0 Then
            MsgBox(getMsgStr("MSG00004", lblOutPutTxt3.Text))
            lblPcbCnt.Focus()
            lblPcbCnt.BackColor = ERROR_INIT_COLOR
            Return False
        End If
        If String.IsNullOrEmpty(lblCrossCnt.Text) = False AndAlso CInt(lblCrossCnt.Text) < 0 Then
            MsgBox(getMsgStr("MSG00004", lblOutPutTxt4.Text))
            lblCrossCnt.Focus()
            lblCrossCnt.BackColor = ERROR_INIT_COLOR
            Return False
        End If
        If String.IsNullOrEmpty(lblCrossPcbCnt.Text) = False AndAlso CInt(lblCrossPcbCnt.Text) < 0 Then
            MsgBox(getMsgStr("MSG00004", lblOutPutTxt5.Text))
            lblCrossPcbCnt.Focus()
            lblCrossPcbCnt.BackColor = ERROR_INIT_COLOR
            Return False
        End If
        If (lblCrossCnt.Text <> "" AndAlso CInt(lblCrossCnt.Text) > 0) And (lblCrossPcbCnt.Text = "" OrElse CInt(lblCrossPcbCnt.Text) = 0) Then
            MsgBox(getMsgStr("MSG00002", lblOutPutTxt5.Text))
            Return False
        End If

        'ADD 苗 2018/3/1 END
        If lblCrossPcbCnt.Text <> "" AndAlso
            lblPcbCnt.Text <> "" AndAlso
            CInt(lblCrossPcbCnt.Text) > CInt(lblPcbCnt.Text) Then
            MsgBox(getMsgStr("MSG10012", lblOutPutTxt5.Text, lblOutPutTxt3.Text)) 'UPD 苗 2018/4/11
            lblCrossPcbCnt.Focus()
            lblCrossPcbCnt.BackColor = ERROR_INIT_COLOR
            Return False

        End If

        'ADD 苗 2018/4/11 BEGIN
        'X印枚数＞X印数の場合、エラー
        If lblCrossPcbCnt.Text <> "" AndAlso
            lblCrossCnt.Text <> "" AndAlso
            CInt(lblCrossPcbCnt.Text) > CInt(lblCrossCnt.Text) Then
            MsgBox(getMsgStr("MSG10012", lblOutPutTxt5.Text, lblOutPutTxt4.Text)) 'UPD 苗 2018/4/11
            lblCrossPcbCnt.Focus()
            lblCrossPcbCnt.BackColor = ERROR_INIT_COLOR
            Return False

        End If
        'ADD 苗 2018/4/11 END

        If IsNothing(lblLostframe) = False AndAlso
           lblLostframe.Text <> "" AndAlso lblPcbCnt.Text <> "" AndAlso
           CInt(lblLostframe.Text) > CInt(lblPcbCnt.Text) Then
            MsgBox(getMsgStr("MSG10012", strLostFrame, lblOutPutTxt3.Text)) 'UPD 苗 2018/4/11

            lblLostframe.Focus()
            lblLostframe.BackColor = ERROR_INIT_COLOR
            Return False
        End If
        Return True

    End Function
    'ADD 苗 2018/1/5 END （X印枚数＞フレーム数の場合、エラー）

    'ADD 苗 2018/1/7 複数ラックの状況
    Protected Overridable Function getMutliStatus() As Double
        Return m_ProcessStatus
    End Function

    'ADD 苗 2018/1/7 最後のラックの判定
    Protected Overridable Function isLastRack(ByVal LotNo As String) As Boolean
        Return False
    End Function

    'ADD 苗 2018/1/10 完成数＝前工程の完成数－不良数
    Protected Overridable Sub setCompleteCnt()
        If lblFailedCnt.Text <> "" Then
            '完成数＝前工程の完成数－不良数
            '
            If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 And doChkFrameID() Then
                'setErrorInfo()
            Else
                lblCompleteCnt.Text = CInt(lblInputCnt.Text) - CInt(lblFailedCnt.Text)
            End If

        End If
    End Sub

    Protected Overridable Sub setCntFromMutliRacks()

    End Sub

    Private Sub txtDiffLot_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDiffLot.TextChanged

    End Sub
    '>>20180113 佐川
    Private Sub settingFaildCount()

        '画面の不良数取得
        Dim calcFaildCount As Double = CInt(lblFailedCnt.Text)
        '処理件数カウント
        Dim iCount As Double = 0
        'ロットNo数(配列に入れるため-1する)
        Dim targetSize As Double = GroupID.Length() - 1

        For Each tagData In GroupID.Reverse
            '>>20180115 安部
            '            If tagData.iInput <= calcFaildCount Then
            If tagData.iFinish <= calcFaildCount Then
                '<<20180115 安部
                '完成数・不良数の計算
                '>>20180115 安部
                'GroupID(targetSize - iCount).iFailed = tagData.iInput
                'GroupID(targetSize - iCount).iFinish = 0
                'calcFaildCount -= tagData.iInput
                GroupID(targetSize - iCount).iFailed = tagData.iFailed + tagData.iFinish
                GroupID(targetSize - iCount).iFinish = 0
                calcFaildCount -= tagData.iFinish
                '<<20180115 安部

            ElseIf calcFaildCount <> 0 Then
                '完成数・不良数の計算
                '>>20180115 安部
                'GroupID(targetSize - iCount).iFailed = calcFaildCount
                'GroupID(targetSize - iCount).iFinish = tagData.iInput - calcFaildCount
                GroupID(targetSize - iCount).iFailed = tagData.iFailed + calcFaildCount
                GroupID(targetSize - iCount).iFinish = tagData.iFinish - calcFaildCount
                '<<20180115 安部
                calcFaildCount = 0

            Else

            End If
            'その他の画面項目はそのまま値を登録する
            '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
            If wf_write_flag = WRITE_WAFER Then
                GroupID(targetSize - iCount).waferNum = CInt(lblPcbCnt.Text)
            Else
                GroupID(targetSize - iCount).iFrame = CInt(lblPcbCnt.Text)
            End If
            '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
            GroupID(targetSize - iCount).iCross = CInt(lblCrossCnt.Text)
            GroupID(targetSize - iCount).iCrossFrm = CInt(lblCrossPcbCnt.Text)
            GroupID(targetSize - iCount).fQflag = CBool(btnQflag.Tag)
            GroupID(targetSize - iCount).fTestflag = m_fTestFlg
            GroupID(targetSize - iCount).fCheckflag = CBool(btnChecked.Tag)

            iCount += 1
        Next
    End Sub
    '<<20180113 佐川

    Overridable Sub AfterRefleshLotBadData()

    End Sub

    Overridable Sub RefleshLotBadData()
        Dim iRet As Integer

        If m_szPreProcLotType = "0" Then
            iRet = m_cLotBadDatat.SaveLotBadData(txtDiffLot.Text, g_CURRENT_EQUIP_ID, g_EQUIP_NO, lblProcessCD.Text, m_szPreProcLotType) 'UPD 苗 2018/1/19 装置No.の対応
        Else
            iRet = m_cLotBadDatat.SaveLotBadData(txtLotNo.Text, g_CURRENT_EQUIP_ID, g_EQUIP_NO, lblProcessCD.Text, m_szPreProcLotType) 'UPD 苗 2018/1/19 装置No.の対応
        End If

        AfterRefleshLotBadData()

    End Sub

    'UPD 苗 2018/1/13
    '着工キャンセル前のクリアメソッド
    Protected Overridable Sub clearData()

    End Sub

    '>>20180117 佐川

    Protected Overridable Sub initializForm()
        '画面入力値をリセットする
        lblkindNm.Text = String.Empty        '品名
        txtDiffLot.Text = String.Empty       'GroupKeyNoテキスト
        lblDiffLotNo.Text = String.Empty     'GroupKeyNoラベル
        txtLotNo.Text = String.Empty         '組立KeyNoテキスト
        lblLotNo.Text = String.Empty         '組立KeyNoラベル
        lblWaferKeyNo.Text = String.Empty    'WaferKeyNo
        lblPbLayout.Text = String.Empty      'PBレイアウト図
        lblShape.Text = String.Empty         '製品外形

        lblBeginTime.Text = String.Empty     '着工日時
        txtOptNoStt.Text = String.Empty      '開始作業者No
        lblInputCnt.Text = String.Empty      '本工程投入数
        lblInputFrm.Text = String.Empty      '基板フレーム枚数
        lblInputCross.Text = String.Empty    '前工程×印数
        lblInputCrossFrm.Text = String.Empty '前工程×印枚数

        lblEndTime.Text = String.Empty       '完成時間
        txtOptNoEnd.Text = String.Empty      '終了作業者No
        lblCompleteCnt.Text = String.Empty   '本工程完成数
        lblPcbCnt.Text = String.Empty        '基板フレーム枚数
        lblCrossCnt.Text = String.Empty      '本工程×印数
        lblCrossPcbCnt.Text = String.Empty   '本工程×印枚数
        lblFailedCnt.Text = String.Empty     '不良数

        lblNextProcs.Text = String.Empty     '次工程
        Button1.Enabled = False
        dtFlow.Rows.Clear()                  '工程フロー
        '不良発生状況
        dtError.Clear()
        dgvError.DataSource = dtError

        'ステータスを着工待ちに変更
        m_ProcessStatus = ProcessStatus.Ready
        '画面表示を更新する
        RaiseEvent ProcessStatusChanged(Me, New EventArgs)

        '>>20180118 佐川
        'フォーカス設定
        If inputLotType.Equals(INPUTLOTTYPE_DIFF) Then
            '拡散ロットの場合、GroupKeyNoにフォーカスを合わせる
            txtDiffLot.Enabled = True
            txtDiffLot.Focus()
        ElseIf inputLotType.Equals(INPUTLOTTYPE_ASM) Then
            '組立ロットの場合、組立KeyNoにフォーカスを合わせる
            txtLotNo.Enabled = True
            txtLotNo.Focus()
        End If
        '<<20180118 佐川

        '>> 20180227 佐川 ICtag初期化
        IcTag = New TagData
        Dim clearTagData = New List(Of TagData)
        GroupID = clearTagData.ToArray
        '<< 20180227 佐川 ICtag初期化

        Me.Text = strTitle '　ADD 苗 2018/5/8

        txtChkInfo.Text = ""
        pnlCheckInfo.Visible = False

    End Sub
    '<<20180117 佐川

    '>>20180118 佐川
    'ChangeAttributeServiceの実行
    Private Sub sendChangeAttributeService(ByVal clientStr As String)
        Dim inputBsite As New InSiteWebService.InChangeAttribute
        Dim outputBsite As New InSiteWebService.OutChangeAttribute
        inputBsite.Employee = txtOptNoEnd.Text  '終了作業者
        inputBsite.Lot = IcTag.szLotNo  'ロット

        'フレーム数.×印フレーム数.×印数.ラック番号.ラック番号.IC廃棄枚数
        Dim udf11String As String = IcTag.iFrame.ToString + "." +
                                    IcTag.iCrossFrm.ToString + "." +
                                    IcTag.iCross.ToString + "." +
                                    changeAttributeRackNo1.ToString + "." +
                                    changeAttributeRackNo2.ToString +
                                    "." + IcTag.iDisposalFrmNum.ToString 'ADD 苗 2018/2/9 IC廃棄枚数をbSIteへ転送要

        inputBsite.Udf11 = udf11String
        PutLog(Me.ToString, "UDF11", "UDF11:" & udf11String)
        'bSiteサービス起動
        outputBsite = ChangeAttributeService_Execute(inputBsite, clientStr)
        '初期化
        outHeader = Nothing
        '戻り値を設定
        outHeader = outputBsite.Header
        'メッセージ拡張
        ReDim Preserve outHeader.ResultCode(1)
        ReDim Preserve outHeader.ResultMessage(1)
        'メッセージ0番目から1番目に移動
        outHeader.ResultCode(1) = outHeader.ResultCode(0)
        outHeader.ResultMessage(1) = outHeader.ResultMessage(0)
        'メッセージ0番目にメッセージを追加
        outHeader.ResultMessage(0) = getMsgStr("MSG10016", udf11String)

        If Not outHeader.Status.Equals("SUCCESS") Then
            PutLog(Me.ToString, "UDF11", "set UDF11 NG")
            ShowBsiteResult(NG)
        Else
            PutLog(Me.ToString, "UDF11", "set UDF11 SUCCESS")
        End If
    End Sub
    '<<20180118 佐川
    'ADD 苗 2018/1/27 BEGIN
    Private Sub lblPcbCnt_TextChanged(sender As Object, e As EventArgs) Handles lblPcbCnt.TextChanged
        setXInnNum()
    End Sub
    '>>20180126 佐川
    'GroupKeyNoタブキー対応
    Private Sub txtDiffLot_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtDiffLot.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtDiffLot_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '組立KeyNoタブキー対応
    Private Sub txtLotNo_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtLotNo.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtLotNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '開始作業者Noタブキー対応
    Private Sub txtOptNoStt_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtOptNoStt.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtOptNoStt_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '終了作業者Noタブキー対応
    Private Sub txtOptNoEnd_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txtOptNoEnd.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtOptNoEnd_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub
    '<<20180126 佐川

    '画面上の×印数を更新（A41）
    Protected Overridable Sub setXInnNum()

    End Sub

    'ADD 苗 2018/1/27 END


    'ADD 苗 2018/1/31 BEGIN 解像度(1024*768）の対応
    Public Sub AutoCtlSize(ByVal inObj As Control)     '自动调整控件大小 

        If inObj Is Nothing Then

            Exit Sub

        End If
        Dim szWidth = 1200 'GetIniFile("RESIZE", "Width", "", g_szInitFileName)
        Dim szHeight = 1000 'GetIniFile("RESIZE", "Height", "", g_szInitFileName)
        Dim szFontSize = 800 'GetIniFile("RESIZE", "FontSize", "", g_szInitFileName)
        Dim szGridColWidth = 1.175 'GetIniFile("RESIZE", "GridColWidth ", "", g_szInitFileName)
        '显示分辨率与窗体工作区的大小的关系：分辨率width*height--工作区（没有工具栏）width*(height-46) 

        '此示例以像素为单位确定桌面的宽度和高度。 

        Dim DeskTopSize As Size = System.Windows.Forms.SystemInformation.PrimaryMonitorSize

        If DeskTopSize.Width = 1024 Then

            Me.Width = DeskTopSize.Width
            Me.Height = 568

            Dim FontSize As Single

            FontSize = 9 * DeskTopSize.Height / szFontSize

            '控件本身**** 

            '控件大小 

            inObj.Size = New Size(Int(inObj.Size.Width * DeskTopSize.Width / szWidth), Int(inObj.Size.Height * DeskTopSize.Height / szHeight))

            '控件位置 

            inObj.Location = New Point(Int(inObj.Location.X * DeskTopSize.Width / szWidth), Int(inObj.Location.Y * DeskTopSize.Height / szHeight))

            '子控件===== 

            Dim n As Integer

            For n = 0 To inObj.Controls.Count - 1

                '只调整子控件的字体。（如果调整窗体的字体，再调用窗体的show方法时，会引发resize从而导致控件的大小和布局改变） 

                inObj.Controls.Item(n).Font = New Font(inObj.Controls.Item(n).Font.FontFamily, FontSize)

                '递归调用（穷举所有子控件） 

                If inObj.Controls.Item(n).Name = "dgvLot" Or inObj.Controls.Item(n).Name = "dgvFlow" Then

                    Dim dgview As DataGridView = CType(inObj.Controls.Item(n), DataGridView)

                    Dim i, j As Integer

                    For j = 0 To dgview.ColumnCount - 1
                        dgview.Columns(j).Width = dgview.Columns(j).Width / szGridColWidth
                        For i = 0 To dgview.RowCount - 1
                            dgview.Item(j, i).Style.Font = New System.Drawing.Font("MS UI Gothic", CSng(FontSize), FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
                        Next
                    Next
                End If
                AutoCtlSize(inObj.Controls.Item(n))
            Next

        End If
    End Sub

    'ADD 苗 2018/1/31 END 解像度(1024*768）の対応
    'ADD 苗 2018/1/31 BGGIN　SF画面の項目を再表示（フレーム数、X印数、X印枚数、空チップ数）
    Private Sub getAtlasUpdatedDetail()

        'DEL Miao 2018/8/20 Begin
        '画面上のフレーム数、X印数、X印枚数、空チップ数を更新する
        Dim dt As DataTable
        dt = m_cLotInfo.getAtlasUpdatedNum(IcTag.szLotNo)
        If dt.Rows.Count <> 0 Then
            'ADD 苗 2018/1/31 
            If dt.Rows(0)("ATLAS_FRAMENUM") = 0 And dt.Rows(0)("ATLAS_BADMARKNUM") = 0 And
               dt.Rows(0)("ATLAS_BADMARK_FRAMENUM") = 0 And dt.Rows(0)("ATLAS_EMPTYCHIPS_NUM") = 0 Then
                '画面上のフレーム数、X印数、X印枚数、空チップ数が更新なし
            Else
                lblPcbCnt.Text = dt.Rows(0)("ATLAS_FRAMENUM") '画面上のフレーム数
                lblCrossCnt.Text = dt.Rows(0)("ATLAS_BADMARKNUM") '画面上のX印数
                lblCrossPcbCnt.Text = dt.Rows(0)("ATLAS_BADMARK_FRAMENUM") '画面上のX印枚数

                If Not IsNothing(lblEmptyChipsCnt) Then
                    lblEmptyChipsCnt.Text = dt.Rows(0)("ATLAS_EMPTYCHIPS_NUM") '画面上の空チップ数 '苗 2018/2/1  lblCrossPcbCnt => lblEmptyChipsCnt
                End If
            End If
        End If
        '------------------------------------------------------------------------------------
        'DEL Miao 2018/8/20 END
        ''ADD Miao 2018/8/20 Begin
        'Dim dtL_FRAME_INFO As DataTable
        'Dim m_lTotalFrameCount As Integer
        'Dim m_lTotalOKCount As Integer
        'Dim m_lTotalNGCount As Integer
        'Dim IPkg As Integer
        'Dim TotalNgFrameCount As Integer
        'dtL_FRAME_INFO = m_cEquipMat.getFrameCount(IcTag.szLotNo, IcTag.szProcsCD)
        'If dtL_FRAME_INFO.Rows.Count > 0 Then

        '    If IsDBNull(dtL_FRAME_INFO.Rows(0).Item(0)) = False Then
        '        m_lTotalFrameCount = CLng(dtL_FRAME_INFO.Rows(0).Item(0))
        '    Else
        '        m_lTotalFrameCount = 0
        '    End If

        '    If IsDBNull(dtL_FRAME_INFO.Rows(0).Item(1)) = False Then
        '        m_lTotalOKCount = CLng(dtL_FRAME_INFO.Rows(0).Item(1))
        '    Else
        '        m_lTotalOKCount = 0
        '    End If

        '    If IsDBNull(dtL_FRAME_INFO.Rows(0).Item(2)) = False Then
        '        m_lTotalNGCount = CLng(dtL_FRAME_INFO.Rows(0).Item(2))
        '    Else
        '        m_lTotalNGCount = 0
        '    End If
        'End If


        'IPkg = m_cEquipMat.getPKGPerFrame(IcTag.szLotNo)

        'TotalNgFrameCount = m_cEquipMat.getTotalNgFrameCount(IcTag.szLotNo, IcTag.szProcsCD, IPkg)

        'lblPcbCnt.Text = m_lTotalFrameCount '画面上のフレーム数
        'lblCrossCnt.Text = (m_lTotalFrameCount * IPkg) - m_lTotalOKCount '画面上のX印数
        'lblCrossPcbCnt.Text = TotalNgFrameCount '画面上のX印枚数

        'If Not IsNothing(lblEmptyChipsCnt) Then
        '    lblEmptyChipsCnt.Text = (m_lTotalFrameCount * IPkg) - m_lTotalOKCount - m_lTotalNGCount '画面上の空チップ数 '苗 2018/2/1  lblCrossPcbCnt => lblEmptyChipsCnt
        'End If
        ''ADD Miao 2018/8/20 END
    End Sub

    'ADD 苗 2018/1/31 BGGIN

    '>>2018/1/30 佐川 キャリア交換対応
    Protected Overridable Sub icTagDataSet()
    End Sub
    '<<2018/1/30 佐川 キャリア交換対応

    ''' <summary>
    ''' bSiteからviewLotServiceを取得する
    ''' </summary>
    ''' <param name="clientProcCd">工程コード</param>
    ''' <returns></returns>
    Public Function getViewLotService(clientProcCd As String) As InSiteWebService.OutViewMachine
        Return ViewMachineService_GetInf(g_EQUIP_NO, clientProcCd)
    End Function

    ''' <summary>
    ''' ViewLotServiceの応答からMaterialInfのカテゴリで絞り込みを行ったListを返却する
    ''' </summary>
    ''' <param name="outMachine">ViewLotService応答</param>
    ''' <param name="categoryType">絞り込みカテゴリ</param>
    ''' <returns></returns>
    Public Function getMachineMaterialListByCategory(outMachine As InSiteWebService.OutViewMachine, ByVal categoryType As String) As List(Of InSiteWebService.Machine_Material)
        If outMachine.Header Is Nothing OrElse outMachine.Header.Status = STS_ERROR Then
            Return New List(Of InSiteWebService.Machine_Material)
        End If
        Return outMachine.MachineInf.MaterialInf.Where(Function(x) x.Category.Trim.Equals(categoryType)).ToList
    End Function
    ''' <summary>
    ''' ViewLotServiceの応答からSubMachineのカテゴリで絞り込みを行ったListを返却する
    ''' </summary>
    ''' <param name="outMachine">ViewLotService応答</param>
    ''' <param name="categoryType">絞り込みカテゴリ</param>
    ''' <returns></returns>
    Public Function getSubMachineListByCategory(outMachine As InSiteWebService.OutViewMachine, ByVal categoryType As String) As List(Of InSiteWebService.Machine_SubMachine)
        If outMachine.Header Is Nothing OrElse outMachine.Header.Status = STS_ERROR Then
            Return New List(Of InSiteWebService.Machine_SubMachine)
        End If
        Return outMachine.MachineInf.SubMachineInf.Where(Function(x) x.MachineCategory.Trim.Equals(categoryType)).ToList
    End Function

    ''' <summary>
    ''' ViewLotService応答の製造条件を連結した文字列を返却
    ''' </summary>
    ''' <param name="getDataList">ViewLotService MaterialInf</param>
    ''' <returns></returns>
    Public Function makeViewMachineTypeString(getDataList As List(Of InSiteWebService.Machine_Material)) As String
        Dim ret = String.Empty
        For Each item In getDataList
            ret += IIf(String.IsNullOrEmpty(ret), item.Type.ToString(), String.Format(":{0}", item.Type.ToString()))
        Next
        Return ret
    End Function
    ''' <summary>
    ''' ViewLotService応答の製造条件を連結した文字列を返却
    ''' </summary>
    ''' <param name="getDataList">ViewLotService SubMachine</param>
    ''' <returns></returns>
    Public Function makeViewMachineTypeString(getDataList As List(Of InSiteWebService.Machine_SubMachine)) As String
        Dim ret = String.Empty
        For Each item In getDataList
            ret += IIf(String.IsNullOrEmpty(ret), item.MachineTypeCode.ToString(), String.Format(":{0}", item.MachineTypeCode.ToString()))
        Next
        Return ret
    End Function

    ' >> 20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
    ''' <summary>
    ''' 作業者入力タイプ
    ''' </summary>
    Public Enum OPERATER_INPUT_TYPE
        ''' <summary>
        ''' 開始作業者
        ''' </summary>
        START_OPE
        ''' <summary>
        ''' 終了作業者
        ''' </summary>
        END_OPE
    End Enum

    ''' <summary>
    ''' 作業者入力後のフォーカスを各画面で設定する
    ''' 各画面でオーバーライドされない場合はTabIndex順に移動する
    ''' </summary>
    ''' <param name="inputType">作業者入力タイプ</param>
    ''' <param name="nowControl">対象コントロール</param>
    Protected Overridable Sub setNextFocus(ByVal inputType As OPERATER_INPUT_TYPE, ByVal nowControl As Control)
        SelectNextControl(nowControl, True, True, True, True)
    End Sub
    ' << 20180301 大賀 作業者入力確定時に次の入力にフォーカスを移動する
    '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
    Public Function CheckInputWaferNum() As Boolean
        Dim inputCnt = IIf(String.IsNullOrEmpty(lblInputFrm.Text), 0, CInt(lblInputFrm.Text))
        Dim pcbCnt = IIf(String.IsNullOrEmpty(lblPcbCnt.Text), 0, CInt(lblPcbCnt.Text))
        If pcbCnt > inputCnt Then
            MsgBox(getMsgStr("MSG10031"))
            Return False
        End If
        Return True
    End Function
    '<<20180302 大賀 GroupKey入力時ウェハ枚数入力

    '>>20180313 大賀 搬送容器桁数チェックを共通化
    Public Function isCheckCaseLength(ByVal txtData As TextBox, ByVal CheckLength As Integer, ByVal Errorlabel As Label) As Boolean
        If m_RackWidthCheck And txtData.Text.Length <> CheckLength Then
            MsgBox(getMsgStr("MSG10032", CheckLength))
            txtData.Enabled = True
            txtData.Focus()
            txtData.SelectAll()
            txtData.BackColor = ERROR_INIT_COLOR
            Errorlabel.BackColor = ERROR_INIT_COLOR
            Return False
        End If
        Return True
    End Function
    '<<20180313 大賀 搬送容器桁数チェックを共通化

    ' >> 20180710 佐川 ラックNo途入力改善
    Public Overridable Sub rackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not txtLotNo.Text.Equals("") Then
            Dim textSys As Control() = Me.Controls.Find(String.Format("txt{0}", sender.Name.ToString.Substring(3, 4)), True)
            Dim lblSys As Control() = Me.Controls.Find(String.Format("lbl{0}", sender.Name.ToString.Substring(3, 4)), True)
            If textSys.Length > 0 AndAlso lblSys.Length > 0 Then
                CType(textSys(0), TextBox).Enabled = True
                CType(textSys(0), TextBox).Focus()
                CType(textSys(0), TextBox).SelectAll()
                CType(textSys(0), TextBox).BackColor = FOCUS_INIT_COLOR
                CType(lblSys(0), Label).BackColor = FOCUS_INIT_COLOR
            End If
        End If
    End Sub
    ' << 20180710 佐川 ラックNo途入力改善

    ' >> 20180712 佐川 ラックID入力追加
    'ラック重複チェック
    Public Function isDiplicateCase(ByVal sender As Object)
        '入力テキスト取得
        Dim txtData As TextBox = CType(sender, TextBox)

        '画面項目数分ループ
        For i = 2 To 6
            Dim txtItem As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, i), False)(0)

            If Not txtData.Name.Equals(txtItem.Name) And txtData.Text.Length > 0 Then
                '入力値と同じ値がある場合はエラー
                If txtData.Text.Equals(txtItem.Text) Then
                    Return False
                End If
            End If
        Next
        Return True
    End Function

    ' テンキー用LostFocus
    Protected Sub txtTenkey_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)

        If String.IsNullOrEmpty(txtData.Text) AndAlso Not txtData.BackColor = ERROR_INIT_COLOR Then

            txtData.BackColor = TENKEY_INIT_COLOR
            lblSys.BackColor = TENKEY_INIT_COLOR

        End If
        txtData.Enabled = False
    End Sub
    ' ラックNo用LostFocus
    Protected Sub txtWB_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)

        If String.IsNullOrEmpty(txtData.Text) AndAlso Not txtData.BackColor = ERROR_INIT_COLOR Then

            txtData.BackColor = BARCODE_INIT_COLOR
            lblSys.BackColor = BARCODE_INIT_COLOR

        End If
        txtData.Enabled = False
    End Sub
    ' << 20180712 佐川 ラックID入力追加
    'ADD MIAO 2018/10/17 Begin
    Public Function DBNullTOblank(obj As Object) As String
        DBNullTOblank = IIf(IsDBNull(obj), "", obj)
    End Function

    Private Sub btnQflag_Click(sender As Object, e As EventArgs) Handles btnQflag.Click

    End Sub
    'ADD MIAO 2019/10/01 
    Private Sub btnUserChange_Click(sender As Object, e As EventArgs)

        'Dim frmUserLogin As New FrmUserLogin
        'Dim clsUserLogin As New clsLoginUser
        Time_LoginUser.Stop()
        pnlUserLogin.Visible = True
        Me.pnlUserLogin.BringToFront()
        txtUser.Select()
        Exit Sub

        ''ユーザ登録画面を呼び出し
        'frmUserLogin.ShowDialog()
        'UserNo = clsUserLogin.getUserNo(g_CURRENT_EQUIP_ID)


        ''着工中の場合、完工作業者を指定する
        'If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Processing Then
        '    txtOptNoEnd.Text = clsUserLogin.getUserNo(g_CURRENT_EQUIP_ID)
        '    Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
        '    txtOptNoEnd_KeyPress(txtOptNoStt, a)
        'End If
        ''着工待ちの場合、着工作業者と完工作業者を指定する
        'If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Ready Then
        '    txtOptNoEnd.Text = clsUserLogin.getUserNo(g_CURRENT_EQUIP_ID)
        '    txtOptNoStt.Text = txtOptNoEnd.Text
        '    Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
        '    txtOptNoStt_KeyPress(txtOptNoStt, a)
        'End If
    End Sub
    'ADD MIAO 2019/1/7 BEGIN
    Private Sub btnEvent_Click(sender As Object, e As EventArgs) Handles btnEvent.Click

        Dim ProgName As String
        Dim aryProgName As String()
        Dim dtDefExec = m_cData.GetDefExec(COMMON_PROC_CD, EXEC_EVENT)
        If dtDefExec.Rows.Count > 0 Then
            'ADD 苗 2018/3/26　BEGIN
            '定義が存在する
            ProgName = dtDefExec.Rows(0)("COMMAND_LINE")
            aryProgName = ProgName.Split(";")
            For i = 0 To aryProgName.Count - 1
                If System.IO.File.Exists(aryProgName(i).ToString) = True Then
                    ProgName = aryProgName(i).ToString
                    Exit For
                End If
            Next
            'ADD 苗 2018/3/26　END
            If Not IsDBNull(dtDefExec.Rows(0)("COMMAND_OPTION")) Then
                Shell(String.Format(ProgName & " " & dtDefExec.Rows(0)("COMMAND_OPTION")))
            End If
        End If

    End Sub
    'ADD MIAO 2018/10/17 END
    'ADD MIAO 2019/10/1 BEGIN
    Private Sub Time_LoginUser_Tick(sender As Object, e As EventArgs) Handles Time_LoginUser.Tick

        chkUserEndTime()

        chkPLT_ZERO()

    End Sub

    Protected Overridable Sub setPLT_FLAG()

    End Sub
    Protected Overridable Sub chkPLT_ZERO()

    End Sub
    'ADD MIAO 2019/10/1 end
#Region "装置連携コマンド通信　自動着完工"
    ''' <summary>
    ''' 結果報告コマンドの送信
    ''' </summary>
    ''' <param name="commandName">コマンド</param>
    ''' <param name="result">結果</param>
    Protected Function sendResponseCommand(ByVal commandName As String, ByVal result As String) As Boolean
        Dim sendCommand = createResponseCommandStr(commandName, result, g_CURRENT_EQUIP_ID)
        PutLog(Me.ToString, "sendCommand", sendCommand)
        Return m_cEquipCommandControl.CommandSend(sendCommand)

    End Function
    Public MPflg As String = "P"
    Public pkgFLG As Integer = 0
    ''' <summary>
    ''' LCコマンドの送信
    ''' </summary>
    Protected Function sendLCCommand(command As String, equipId As String, name As String, operatorId As String, lotNo As String, compnum As String, badnum As String, framenum As String, package As String, crossnum As String, waferNo As String, pbLayout As String, shape As String) As Boolean
        Dim sendCommand = createLCCommandStr(command, equipId, name, setLCuser(operatorId), lotNo, compnum, badnum, framenum, package, crossnum, waferNo, pbLayout, shape, MPflg, pkgFLG)
        LC_COMMAND = sendCommand
        PutLog(Me.ToString, "sendCommand", sendCommand)
        Return m_cEquipCommandControl.CommandSend(sendCommand)
    End Function

    Private Function setLCuser(_operatorId As String) As String
        If _operatorId = "" Then
            Dim objUserLogin As New clsLoginUser
            Dim a = objUserLogin.getUserNo(g_CURRENT_EQUIP_ID)
            If a = "" Then
                setLCuser = "INSITEADMIN"
            Else
                setLCuser = a
            End If
        Else
            setLCuser = _operatorId
        End If
    End Function
    ''' <summary>
    ''' LFコマンドの送信
    ''' </summary>
    Protected Function sendLFCommand(command As String, equipId As String, lotNo As String, name As String) As Boolean
        Dim sendCommand = createLFCommand(command, equipId, lotNo, name)
        PutLog(Me.ToString, "sendCommand", sendCommand)

        Return m_cEquipCommandControl.CommandSend(sendCommand)
    End Function

    ''' <summary>
    ''' DMコマンドの送信
    ''' </summary>
    Protected Function sendDMCommand(command As String, rtn As String, equipId As String, matType As String, matName As String, lotNo As String, CaseNo As String) As Boolean
        Dim sendCommand = createDMCommand(command, rtn, equipId, matType, matName, lotNo, CaseNo， UserNo)
        PutLog(Me.ToString, "sendCommand", sendCommand)

        Return m_cEquipCommandControl.CommandSend(sendCommand)
    End Function
    ' TCPクライアント用イベント
    Protected WithEvents m_cEquipCommandControl As clsEquipCooperateCommand
    Delegate Sub TCPCLEventDelegate(e As TCPListener.TCPEventArgs)
    ''' <summary>
    ''' イベント受信
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub TCPCLEvent(sender As System.Object, e As TCPListener.TCPEventArgs) Handles m_cEquipCommandControl.tcpevent
        Debug.WriteLine("TCPCLEvent in")
        Dim adrData As New TCPCLEventDelegate(AddressOf DoTCPCLEvent)
        Try
            Me.BeginInvoke(adrData, e)
        Catch ex As Exception
            MsgBox(getMsgStr("MSG00186"))
        End Try
    End Sub
    Private Sub DoTCPCLEvent(e As TCPListener.TCPEventArgs)
        HideCommandWaiting()
        ' 接続完了
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Connect Then
            Debug.WriteLine("接続完了")
            MsgBox("接続完了")
        End If
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Shutdown Then
            Debug.WriteLine("接続切断")
            MsgBox("接続切断")
        End If
        ' データ受信
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Receive Then
            'MsgBox("データ受信") 'TODO:DEL
            Debug.WriteLine("データ受信")
            Dim receiveDataStr = Encoding.ASCII.GetString(e.receiveData, 0, e.receiveData.Count())
            Debug.WriteLine(receiveDataStr)
            PutLog(Me.ToString, "RECEIVEDATA", receiveDataStr)

            'TODO:OdHの判断、マルチコマンド　OR　分割のコマンド２０１９１２０３
            receiveDataStrList = receiveDataStr.Split(vbCr)

            For i As Integer = 0 To receiveDataStrList.Count - 1
                If receiveDataStrList(i).Trim <> "" Then
                    If perReceiveDataStr <> "" Then
                        receiveDataStrList(i) = perReceiveDataStr & receiveDataStrList(i)
                        perReceiveDataStr = ""
                    End If
                    ' コマンドID読み出し(2byte)
                    Dim cmdId = GetCommandData(receiveDataStrList(i), IDENTIFIER_COMMANDID)
                    ' 読み出したコマンドが一致しているので正常と判断
                    Select Case cmdId
                        Case COMMAND_LN
                            commandSize = 487
                        Case COMMAND_LH
                            commandSize = 313
                        Case COMMAND_LD
                            commandSize = 37
                        Case COMMAND_DL
                            commandSize = 180
                        Case Else
                            commandSize = 0
                    End Select
                    'MsgBox("收到指令字符长度：" & receiveDataStrList(i).Count & vbCrLf & receiveDataStrList(i))
                    '残った内容はコマンドのサイズではなければ、一度保存する
                    If receiveDataStrList(i).Count < commandSize Then
                        perReceiveDataStr = receiveDataStrList(i)
                        Exit Sub
                    ElseIf receiveDataStrList(i).Count > commandSize Then
                        PutLog(Me.ToString, "RECEIVEDATA ERROR", getMsgStr("MSG00170", cmdId & "命令"))
                        setCheckInfo(getMsgStr("MSG00170", cmdId & "命令"))
                        Exit Sub
                    End If

                    'MsgBox(receiveDataStr) 'TODO:DEL
                    'PutLog(Me.ToString, "ReceiveData" , receiveDataStr)
                    ' 受信コマンド解析
                    Dim Data = CommandAnalize(receiveDataStrList(i))

                    ' 受信コマンド解析に失敗した場合
                    If Data IsNot Nothing AndAlso Data.cmdAnalizeResult = CMD_ANALIZE_RESULT_ERROR Then
                        ' コマンドID読み出し(2byte)
                        Dim commandId = Data.commandId
                        ' 読み出したコマンドが一致しているので正常と判断
                        Select Case commandId
                            Case COMMAND_LN
                                sendResponseCommand(COMMAND_IT, RESPONSE_COMMAND_NG)
                            Case COMMAND_LH
                                sendResponseCommand(COMMAND_IU, RESPONSE_COMMAND_NG)
                            Case COMMAND_LD
                                sendResponseCommand(COMMAND_IT, RESPONSE_COMMAND_NG)
                            Case COMMAND_LG
                                sendResponseCommand(COMMAND_IU, RESPONSE_COMMAND_NG)
                            Case Else
                        End Select

                        Data = Nothing
                        Exit Sub
                    End If
                    If Data.equipId <> g_CURRENT_EQUIP_ID Then
                        setCheckInfo(getMsgStr("MSG00011", "接收到的设备ID"))
                        Data = Nothing
                    End If
                    'MsgBox(Data.commandId) 'TODO:DEL
                    ' 受信コマンド解析
                    CommandReceive(Data)
                End If
            Next
        End If
        ' Exception
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Exception Then
            Debug.WriteLine("Exception受信")
            Debug.WriteLine(e.exception.Message)
            CommandReceive(Nothing)
        End If
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Timeout Then
            Debug.WriteLine("timeout受信")
            CommandReceive(Nothing)
        End If
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Cancel Then
            Debug.WriteLine("Cancel受信")
            CommandReceive(Nothing)
        End If
        If e.eventType = TCPListener.TCPEventArgs.TcpEventType.Retry Then
            Debug.WriteLine("retry受信")
            m_cEquipCommandControl.CommandConnect()
        End If
    End Sub
#End Region


#Region "自動着完工　ほかの処理"
    ''' <summary>
    ''' コマンド受信
    ''' 受信コマンドの解析結果を各画面に渡す
    ''' </summary>
    ''' <param name="receiveData">受信コマンド</param>
    Protected Overridable Sub CommandReceive(receiveData As receiveCommandData)
        'MsgBox("Baseクラスの「CommandReceive」メソッドに入った！")
        HideCommandWaiting()
        If IsNothing(receiveData) Then
            Exit Sub
        End If

        '--------着工コマンド処理-------    
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LN Then
            Dim strLotNo As String = ""
            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                Exit Sub
            End If
            PutLog(Me.ToString, "LN", "Begin") '2020/8/8 ver.58
            LN_COLSED = False
            'MsgBox("LN　コマンドを受け入れた！")
            LN_FLAG = True

            If NP_IU_RTN = False And setBufferLN() Then 'ADD 2020/8/17 miaojf Ver.70
                PutLog(Me.ToString, "LN", "NP_IU_RTN = False") '2020/8/8 ver.58
                WaitLnCommand = receiveData
                Exit Sub
            End If
            'RACKからLOT情報を取得し、画面に設定する
            If IsNothing(IcTag.szLotNo) OrElse IcTag.Status = TagProcessStatus.Ready OrElse isSameRackNo(receiveData.LrackNoList(0)) = False OrElse chkLN() Then
                PutLog(Me.ToString, "LN->LN", "DO") '2020/8/8 ver.58

                clearForm()
                'Sleep(2000)
                '入力ラックNoからロットNoを取得
                setBeforeRackNo(receiveData.LrackNoList(0))

                strLotNo = getLotNoByRack(receiveData.LrackNoList(0))
                Me.Refresh()
                If strLotNo = "" Then
                    setCheckInfo(getMsgStr("MSG10059", receiveData.LrackNoList(0)))
                    PutLog(Me.ToString, "RECEIVEDATA LN ERROR", getMsgStr("MSG10059", receiveData.LrackNoList(0))) '2020/8/8 ver.57
                    Exit Sub
                End If
                Command_LD_Received = False

                txtLotNo.Text = strLotNo
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))

                Me.Refresh()
                setBeforeRackNo(receiveData.LrackNoList(0))
                'If checkBsiteMachineInf() = False Then Exit Sub
            End If

            PutLog(Me.ToString, "LN", "End") '2020/8/8 ver.58
            LN_COLSED = True
        End If
        '<LD>
        If receiveData.commandId = COMMAND_LD Then
            If LN_COLSED = False Then
                PutLog(Me.ToString, "LD", "LN_COLSED = False") '2020/8/8 ver.58
                WaitLDCommand = receiveData
                Exit Sub
            End If
            PutLog(Me.ToString, "Command_LD_Received", Command_LD_Received)
            PutLog(Me.ToString, "reconfirmNBIGS", reconfirmNBIGS)


            'MsgBox("LD　コマンドを受け入れた！")
            If Command_LD_Received = True Then

                setCheckInfo("收到的为LD,设备应先发送LN命令,本次处理中止")
                PutLog(Me.ToString, "RECEIVEDATA LD ERROR", "DB:收到的为LD,设备应先发送LN命令,本次处理中止") '2020/8/8 ver.57

                Exit Sub
            End If
            'ADD MIAOJF 2020/07/18 begin
            If reconfirmNBIGS = True Then
                If receiveData.result = COMMAND_RESULT_OK Then
                    setCheckInfo(getMsgStr("MSG00117", "照合成功。"))
                    PutLog(Me.ToString, "RECEIVEDATA LD OK2", getMsgStr("MSG00117", "照合成功。")) '2020/8/8 ver.57

                Else
                    ShowCommandResult(receiveData.result)
                    PutLog(Me.ToString, "RECEIVEDATA LD NG2", "照合失败。") '2020/8/8 ver.57

                End If
                reconfirmNBIGS = False
                Exit Sub
            End If
            'ADD MIAOJF 2020/07/18 END
            PutLog(Me.ToString, "receiveData.result", receiveData.result)
            If receiveData.result = COMMAND_RESULT_OK Then
                PutLog(Me.ToString, "LD IN BEGIN", receiveData.result)

                Command_LD_Received = True
                WorkStart()
                Command_LD_Received = False
                PutLog(Me.ToString, "LD IN END", receiveData.result)

            Else
                ShowCommandResult(receiveData.result)
                PutLog(Me.ToString, "RECEIVEDATA LD NG", "照合失败。") '2020/8/8 ver.57

            End If
        End If

        '--------完工コマンド処理-------
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LH Then

            '----------2021 DC、TC、LTF自动着工对应0619 begin
            If CUSTOMIZES_DC_TC_LTF_AUTO = True Then
                If doCommandLH() = False Then
                    Exit Sub
                End If
            End If
            '----------2021 DC、TC、LTF自动着工对应0619 end

            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                Exit Sub
            End If
            PutLog(Me.ToString, "LH", "Begin") '2020/8/8 ver.58

            'MsgBox("LH　コマンドを受け入れた！")
            If isSameLot(receiveData) = False Then
                '入力ラックNoからロットNoを取得
                Dim lot As String = getLotNoByRack(receiveData.LrackNoList(0))
                If lot = "" Then
                    Dim str As String = "根据着工料盒找不到关联组立KeyNo.(着工料盒：" & receiveData.LrackNoList(0) & ")"
                    PutLog(Me.ToString, "LH ERROR", str) '2020/8/8 ver.58
                    setCheckInfo(str)
                    Exit Sub
                End If

                txtLotNo.Text = lot
                LC_SEND_FLG = False
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                LC_SEND_FLG = True
                setBeforeRackNo(receiveData.LrackNoList(0))
                'If checkBsiteMachineInf() = False Then Exit Sub

            End If

            If chkLH() = False Then
                PutLog(Me.ToString, "LH", "处理LOT : " & IcTag.szLotNo & "不是着工中状态。") '2020/8/8 ver.58
                setCheckInfo("处理LOT : " & IcTag.szLotNo & "不是着工中状态。处理中止。")
                IcTag = New TagData 'add 20200911 miaojf 
                Exit Sub
            End If

            LH_FLAG = True
            '不良内容をSF画面に表示する
            'setErrorInfo(receiveData)
            '完了MSラックNo.の設定
            If setAfterRackNo(receiveData) = False Then
                setCheckInfo("指令中的【完了料盒号】读取错误。请检查设备。")
                PutLog(Me.ToString, "RECEIVEDATA LD NG", "指令中的【完了料盒号】读取错误。请检查设备。") '2020/8/8 ver.57
                Exit Sub
            End If
            'WB 画面清空后再发NP,IU.为NP所准备
            NPP.szLotNo = IcTag.szLotNo
            NPP.szDifLotNo = IcTag.szDifLotNo
            NPP.ProcessCD = lblProcessCD.Text
            NPP.EQUIP_ID = g_CURRENT_EQUIP_ID
            NPP.EQUIP_No = lblEquipID.Text
            NPP.OptNoEnd = txtOptNoEnd.Text
            NPP.kindNm = lblkindNm.Text
            NPP.Shape = lblShape.Text
            NPP.PbLayout = lblPbLayout.Text

            If EndCheck() AndAlso lotEndCheck() Then
                'ADD 2020/9/12 miaojf Ver.80
                If IsNothing(outHeader) = False Then
                    outHeader.Status = STS_WARNING
                End If
                'bSiteへ計上処理
                btnTotalComp.PerformClick()
                '画面表示を初期化
                setinitializForm_FLG()

                If IsNothing(outHeader) = False AndAlso STS_SUCCESS.Equals(outHeader.Status) And initializForm_FLG = True Then 'UPD 2020/9/12 miaojf Ver.80
                    initializForm()
                End If
                ''WB 画面清空后再发NP,IU.
                'SendNPtoMPC()

                PutLog(Me.ToString, "LH", "END") '2020/8/8 ver.58
            Else
                rtnNG_TO_MPC()
                'setCheckInfo("不满足完工条件，请检查设备页的信息是否正确。")
                PutLog("LH NG", txtOptNoEnd.Text, "完成条件は満たされていません。処理終了。")
                Exit Sub
            End If

        End If
        '--------材料補充処理-------
        If receiveData.commandId = COMMAND_DL Then

            '====================================
            'ShowBsiteWaiting()

            ''設備の情報（治具、材料）を退避する
            'getMachinInf()

            ''材料ロットを補充
            'MaterialLotSetup(receiveData)
            ''型名を補充
            '====================================


            '処理モード１か判断：１ではない場合、処理中止 1の場合、処理続行
            If receiveData.mode <> "1" Then Exit Sub
            If chkMaterialType(receiveData.matType) = True Then
                CallAtlasExec(receiveData.matType, receiveData.matName)

                'bSiteのエラーメッセージ
                'Dim bsiteMess As New clsDbBsiteMess
                'Dim errDt = bsiteMess.GetErrorList(m_szIP)

                ''検索結果がある場合、NG。でなければ、OK
                Dim rtn As String = OK
                If bsiteRtn Then
                    rtn = OK
                Else
                    rtn = NG
                End If
                'setChangeForPQC(receiveData)
                If receiveData.matType = "WB_CAPILLARY" Then
                    setChangeForPQC("WB_CAPILLARY")
                End If
                'DMコマンドの送信
                sendDMCommand(COMMAND_DM, rtn, lblEquipID.Text, receiveData.matType, receiveData.matName, receiveData.matLotNo, receiveData.caseNo)
                'If bsiteRtn Then setChangeForPQC(receiveData)
                '画面刷新
                jyokenRefresh()
            End If

        End If
    End Sub

    Overridable Function doCommandLH()
        Return True
    End Function

    Protected Function chkErrorRackNo(receiveData As receiveCommandData, cmdID As String) As Boolean
        Dim rtn As Boolean = True
        If receiveData.LrackNoList.Count > 0 Then
            For i As Integer = 0 To receiveData.LrackNoList.Count - 1
                If receiveData.LrackNoList(i) = "ERROR" Then
                    setCheckInfo("读取的着工料盒为【ERROR】，请重新处理。")
                    PutLog(Me.ToString, cmdID, "着工料盒为【ERROR】") '2020/8/8 ver.58
                    rtn = False
                    Exit For
                End If
            Next
        End If

        If receiveData.UrackNoList.Count > 0 Then
            For i As Integer = 0 To receiveData.UrackNoList.Count - 1
                If receiveData.UrackNoList(i) = "ERROR" Then
                    setCheckInfo("读取的完工料盒为【ERROR】，请重新处理。")
                    PutLog(Me.ToString, cmdID, "完工料盒为【ERROR】") '2020/8/8 ver.58
                    rtn = False
                    Exit For
                End If
            Next
        End If
        Return rtn
    End Function
    Overridable Sub jyokenRefresh()

    End Sub
    ''' <summary>
    ''' 是否时行LN命令的预存
    ''' </summary>
    ''' <returns></returns>
    Overridable Function setBufferLN() As Boolean
        Return False
    End Function
    ''' <summary>
    ''' WB工程，当第一个rack完工中，来了第二个料盒的信息，要判断正在做的rackNo和新来的rackNo是否一致。
    ''' 不一致的时候，返回false
    ''' </summary>
    ''' <param name="rackNo">新来的料盒</param>
    ''' <returns></returns>
    Overridable Function isSameRackNo(rackNo As String) As Boolean
        Return True
    End Function

    Overridable Function chkMatChanged() As Boolean
        Return False
    End Function

    Protected Sub chkPQC()

        Dim jss As New JavaScriptSerializer
        Dim dic As ArrayList = New ArrayList()

        Dim drow As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
        Try
            Dim pqc As New ServiceReferencePQC.CommonServiceClient
            Dim tokenR As New ServiceReferencePQC.getToken
            Dim tokenRB As New ServiceReferencePQC.getTokenBody
            Dim token As New ServiceReferencePQC.getTokenResponse
            Dim tokenSTR As String
#Region "令牌"
            '-----得到令牌 BEGIN -------
            drow.Add("user", "sfadmin")
            drow.Add("pwd", "sfadmin")
            dic.Add(drow)
            Dim SerializeSTR As String = jss.Serialize(dic)
            SerializeSTR = SerializeSTR.Replace("[", "")
            SerializeSTR = SerializeSTR.Replace("]", "")

            tokenRB.listjsonString = SerializeSTR
            tokenR.Body = tokenRB
            token = pqc.ServiceReferencePQC_CommonService_getToken(tokenR)

            Dim js As JObject
            js = JObject.Parse(token.Body.listjsonString.ToString)

            tokenSTR = js.SelectToken("token")
            '-----得到令牌 END -------

#End Region

            Dim paramAl As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
            paramAl.Add("keyno", txtLotNo.Text）
            paramAl.Add("deviceNum", lblEquipID.Text）
            paramAl.Add("Standby1", ""）
            paramAl.Add("Standby2", ""）
            paramAl.Add("Standby3", ""）
            paramAl.Add("Standby4", ""）
            paramAl.Add("Standby5", ""）

            Dim AllParam As String
            Dim AllParamAl As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
            AllParamAl.Add("user", "sfadmin")
            AllParamAl.Add("token", tokenSTR)
            AllParamAl.Add("param", paramAl)
            dic.Clear()
            dic.Add(AllParamAl)
            AllParam = jss.Serialize(dic)
            AllParam = AllParam.Substring(1, AllParam.Length - 2)
            Dim rSF As New ServiceReferencePQC.SFKeyNoUpdate
            rSF.Body = New ServiceReferencePQC.SFKeyNoUpdateBody
            rSF.Body.listjsonString = AllParam

            Dim rSFq As ServiceReferencePQC.SFKeyNoUpdateResponse
            rSFq = pqc.ServiceReferencePQC_CommonService_SFKeyNoUpdate(rSF)
            js = JObject.Parse(rSFq.Body.listjsonString.ToString)
            If js.SelectToken("message").ToString = "需实施PQC" Then
                'MsgBox(js.SelectToken("message").ToString)

                Me.pnlCheckInfo.Visible = True
                Me.pnlCheckInfo.BringToFront()

                txtChkInfo.Text = js.SelectToken("message").ToString & vbCrLf

            End If
        Catch ex As Exception
            MsgBox(getMsgStr("MSG10061"))
        End Try


    End Sub
    Protected Sub setChangeForPQC(inMatType As String, Optional ByVal lc As String = "",
         Optional ByVal mc As String = "", Optional ByVal sc As String = "", Optional ByVal met As String = "交换")

        Dim jss As New JavaScriptSerializer
        Dim dic As ArrayList = New ArrayList()

        Dim drow As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
        Try

            Dim pqc As New ServiceReferencePQC.CommonServiceClient
            Dim tokenR As New ServiceReferencePQC.getToken
            Dim tokenRB As New ServiceReferencePQC.getTokenBody
            Dim token As New ServiceReferencePQC.getTokenResponse
            Dim tokenSTR As String

#Region "令牌"
            '-----得到令牌 BEGIN -------
            drow.Add("user", "sfadmin")
            drow.Add("pwd", "sfadmin")
            dic.Add(drow)
            Dim SerializeSTR As String = jss.Serialize(dic)
            SerializeSTR = SerializeSTR.Replace("[", "")
            SerializeSTR = SerializeSTR.Replace("]", "")

            tokenRB.listjsonString = SerializeSTR
            tokenR.Body = tokenRB
            token = pqc.ServiceReferencePQC_CommonService_getToken(tokenR)

            Dim js As JObject
            js = JObject.Parse(token.Body.listjsonString.ToString)

            tokenSTR = js.SelectToken("token")
            '-----得到令牌 END -------
#End Region
#Region "设置变化点"
            Dim matType As String = ""
            Select Case inMatType
                Case "WB_CAPILLARY"
                    matType = "劈刀"
                Case "WB_WIRE"
                    matType = "线材"
                Case "DB_PASTE"
                    matType = "银浆"
                Case "MD_RESIN"
                    matType = "树脂"
                    '------------2021 PQC对应--------------
                Case "DB_TAPE"
                    matType = "胶布"
                Case "DB_BLADE"
                    matType = "刀具"
                Case "WAFER_LOT"
                    matType = "车品Wafer lot交换"
                    '------------2021 PQC对应--------------
            End Select

            Dim changePAl As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
            changePAl.Add("largeClassify", IIf(lc = "", "材料交换", lc))
            changePAl.Add("middleClassify", IIf(mc = "", "间直材", mc))
            changePAl.Add("smallClassify", IIf(sc = "", matType, sc))
            changePAl.Add("mainMethod", met)
            dic.Clear()
            dic.Add(changePAl)
            Dim cp As String
            cp = jss.Serialize(dic)

            Dim paramAl As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
            paramAl.Add("keyno", txtLotNo.Text)
            paramAl.Add("mainDepNum", "")
            paramAl.Add("project", "")
            paramAl.Add("type", ""）
            paramAl.Add("deviceNum", lblEquipID.Text）
            paramAl.Add("changepoint", cp）
            paramAl.Add("ESMSTime", ""）
            paramAl.Add("Sendercode", "SF"）
            paramAl.Add("EmployeeID ", txtOptNoStt.Text）
            paramAl.Add("Standby1", ""）
            paramAl.Add("Standby2", ""）
            paramAl.Add("Standby3", ""）
            paramAl.Add("Standby4", ""）
            paramAl.Add("Standby5", "4"）
            'dic.Clear()
            'dic.Add(paramAl)
            'param = jss.Serialize(dic)
            'param = param.Replace("[", "")
            'param = param.Replace("]", "")
            'param = param.Replace("%", changeP)

            Dim AllParam As String
            Dim AllParamAl As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
            AllParamAl.Add("user", "sfadmin")
            AllParamAl.Add("token", tokenSTR)
            AllParamAl.Add("param", paramAl)
            dic.Clear()
            dic.Add(AllParamAl)
            AllParam = jss.Serialize(dic)
            AllParam = AllParam.Replace("\", "")
            AllParam = AllParam.Replace(Chr(34) & "[", "[")
            AllParam = AllParam.Replace("]" & Chr(34), "]")

            AllParam = AllParam.Substring(1, AllParam.Length - 2)


            Dim scp As New ServiceReferencePQC.sendChangePoint
            scp.Body = New ServiceReferencePQC.sendChangePointBody
            scp.Body.listjsonString = AllParam
            Dim scpR As ServiceReferencePQC.sendChangePointResponse
            PutLog(Me.ToString, "PQC_S", scp.Body.listjsonString)
            scpR = pqc.ServiceReferencePQC_CommonService_sendChangePoint(scp)
            PutLog(Me.ToString, "PQC_R", scpR.Body.listjsonString.ToString)

            js = JObject.Parse(scpR.Body.listjsonString.ToString)
            If js.SelectToken("flag").ToString.ToUpper = "FALSE " Then
                MsgBox(getMsgStr("MSG00123"))
            End If
#End Region

        Catch ex As Exception
            MsgBox(getMsgStr("MSG10061"))
        End Try
    End Sub
    Overridable Function checkBsiteMachineInf() As Boolean
        Return True
    End Function
    ''' <summary>
    ''' 材料区分が本工程の区分かどうか判断
    ''' </summary>
    ''' <param name="materialType">材料区分</param>
    ''' <returns>判断結果</returns>
    Protected Overridable Function chkMaterialType(materialType As String) As Boolean
        Return True
    End Function

    ''' <summary>
    ''' atlasの材料補充を呼び出す
    ''' </summary>
    ''' <param name="materialType">材料区分</param>
    ''' <param name="mat">材料名</param>
    Protected Overridable Sub callAtlasExec(materialType As String, mat As String)

    End Sub

    ''' <summary>
    ''' 設備で設定している材料と治具を取得
    ''' </summary>
    Protected Sub getMachinInf()

        Dim mOutParam As New InSiteWebService.OutViewMachine
        Dim InHeader As New InSiteWebService.InHeader
        Dim clientStr As String = GetBsiteClientString()

        mOutParam = ViewMachineService_GetInf(lblEquipID.Text, clientStr) '装置検索
        If (mOutParam.Header.Status = "SUCCESS") Then
            MaterialLotList.Clear()
            MachineNameList.Clear()
            '材料情報を取得
            For Each OutMaterial As InSiteWebService.Machine_Material In mOutParam.MachineInf.MaterialInf
                MaterialLotList.Add(OutMaterial.Lot)
                'textBox8.Text += String.Join(" | ", New String[] { OutMaterial.Type, OutMaterial.Lot, OutMaterial.OriginalLot, OutMaterial.Category }) + "\r\n";
            Next
            '治具情報を取得
            For Each OutSubMachine As InSiteWebService.Machine_SubMachine In mOutParam.MachineInf.SubMachineInf
                MachineNameList.Add(OutSubMachine.Name)
                'textBox9.Text += String.Join(" | ", New String[] { OutSubMachine.MachineTypeCode, OutSubMachine.Name, OutSubMachine.Description, OutSubMachine.MachineCategory }) + "\r\n";
            Next
        End If

    End Sub

    ''' <summary>
    ''' 材料ロットのセットアップ
    ''' </summary>
    ''' <param name="receiveData">受入コマンド</param>
    Protected Overridable Sub MaterialLotSetup(receiveData As receiveCommandData)
        '--------処理モード０--------
        '追加要
        '--------処理モード１--------
        '追加要？？？
        '--------処理モード２--------
        Dim InViewLot As New InSiteWebService.InViewLot
        Dim OutViewLot As New InSiteWebService.OutLotStd

        InViewLot.Name = receiveData.matLotNo '材料ロットNo,
        Dim clientStr As String = GetBsiteClientString()
        OutViewLot = ViewLotServiceGet(InViewLot, clientStr)

        If (OutViewLot.Header.Status = "SUCCESS") Then
            Dim InMaterial As New InSiteWebService.Machine_Material
            Dim InMaterialArr(1) As InSiteWebService.Machine_Material
            Dim inputBsite_MachineSetup As New InSiteWebService.InMachineSetup
            Dim outputBsite_MachineSetup As New InSiteWebService.OutMachineSetup
            '治具情報
            Dim MachineNameListArr(MachineNameList.Count) As String
            For i As Integer = 0 To MachineNameList.Count - 1
                MachineNameListArr(i) = MachineNameList(i)
            Next

            '材料ロットの情報を取得
            InMaterial.Type = OutViewLot.LotInf.Product
            InMaterial.TypeRev = OutViewLot.LotInf.ProductRev
            InMaterial.Lot = OutViewLot.LotInf.Name
            InMaterial.OriginalLot = OutViewLot.LotInf.OriginalLot
            InMaterial.Qty = OutViewLot.LotInf.Qty
            InMaterial.DueDate = OutViewLot.LotInf.DueDateE
            InMaterial.DueDateW = OutViewLot.LotInf.DueDateW
            InMaterialArr(0) = InMaterial

            inputBsite_MachineSetup.Employee = txtOptNoStt.Text
            'inputBsite_MachineSetup.CloseLot TODO ADD
            inputBsite_MachineSetup.Machine = lblEquipID.Text
            inputBsite_MachineSetup.MaterialInf = InMaterialArr
            inputBsite_MachineSetup.SubMachine = MachineNameListArr '元の治具を保留

            '装置設定
            outputBsite_MachineSetup = MachineSetupService_Execute(inputBsite_MachineSetup)

            '戻り情報を保持
            outHeader = outputBsite_MachineSetup.Header
            lblWait.Visible = False
            Me.Enabled = True
            Me.Cursor = Cursors.Arrow

            Dim rtnDM As String
            If STS_SUCCESS.Equals(outHeader.Status) Then
                rtnDM = OK
            Else
                rtnDM = NG
            End If
            ShowBsiteResult(rtnDM)

            'DMコマンドの送信
            sendDMCommand(COMMAND_DM, rtnDM, lblEquipID.Text, InMaterial.Type, InMaterial.TypeRev, InMaterial.Lot, "")

        End If
    End Sub


    ''' <summary>
    ''' 同じLotであるかどうか判断
    ''' </summary>
    ''' <param name="receiveData">コマンド</param>
    ''' <returns></returns>
    Public Function isSameLot(receiveData As receiveCommandData) As Boolean
        Dim rtn As Boolean = True

        If IsNothing(IcTag.szLotNo) OrElse IcTag.szLotNo = "" OrElse txtLotNo.Text = "" Then
            rtn = False
            Return rtn
        End If

        Dim containerList As List(Of String) = New List(Of String)
        If IcTag.container1 <> "" Then containerList.Add(IcTag.container1)
        If IcTag.container2 <> "" Then containerList.Add(IcTag.container2)
        If IcTag.container3 <> "" Then containerList.Add(IcTag.container3)
        If IcTag.container4 <> "" Then containerList.Add(IcTag.container4)
        If IcTag.container5 <> "" Then containerList.Add(IcTag.container5)


        For i As Integer = 0 To receiveData.LrackNoList.Count - 1

            If receiveData.LrackNoList(i) <> "" Then
                Dim j As Integer
                j = i
                If containerList.Any(Function(x) x = receiveData.LrackNoList(j)) = False Then
                    rtn = False
                End If
            End If
        Next

        Return rtn

    End Function

    ''' <summary>
    ''' 受入ラック設定
    ''' </summary>
    Protected Overridable Sub setBeforeRackNo(Optional inputRackNo As String = "")

    End Sub

    ''' <summary>
    '''　完了ラック設定
    ''' </summary>
    ''' <param name="receiveData">受け入れたデータ</param>
    Protected Overridable Function setAfterRackNo(receiveData As receiveCommandData) As Boolean
        Return True
    End Function

    ''' <summary>
    ''' コマンド応答作成
    ''' </summary>
    ''' <param name="command">受信コマンド</param>
    ''' <param name="result">結果</param>
    Protected Overridable Sub makeResponseCommand(command As String, result As String)
    End Sub

    ''' <summary>
    ''' コマンド受信結果表示
    ''' </summary>
    ''' <param name="result">結果</param>
    Public Sub ShowCommandResult(result As Integer)
        Dim ShowMsg As New ShowSelectForm
        Dim ShowText = String.Empty
        Dim ShowColor = Color.Green
        If result = COMMAND_RESULT_OK Then
            Exit Sub
            'ShowText = getMsgStr("MSG00172")
            'ShowColor = Color.Green
        Else
            ShowText = getMsgStr("MSG00173", result, getCommandResultString(result))
            ShowColor = Color.Red
        End If
        With ShowMsg
            .lblText.Text = ShowText
            .lblText.BackColor = ShowColor
            .lblText.Height = 100
            .lblText.Font = New System.Drawing.Font("ＭＳ ゴシック", 28.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
            .lblText2.Text = ""
            .lblText2.BackColor = ShowColor

            .BackColor = ShowColor
            .Button1.Visible = False
            .Button2.Visible = False
            .Button3.Visible = False
            .Button4.Text = "OK"
            .Button4.DialogResult = DialogResult.OK
            .Button4.Visible = True
            .StartPosition = FormStartPosition.CenterParent
            .ShowDialog()
        End With

    End Sub

    ''' <summary>
    ''' 装置ID一致チェック
    ''' </summary>
    ''' <param name="equipId">装置ID</param>
    ''' <returns></returns>
    Public Function isEquipIdMatch(equipId As String) As Boolean
        If equipId <> lblEquipID.Text Then
            MsgBox(getMsgStr("MSG00171"))
            Return False
        End If
        Return True
    End Function

    ''' <summary>
    ''' 自動・手動切替設定が必要な画面でオーバーライドする
    ''' </summary>
    ''' <param name="mode">True:自動</param>
    Protected Overridable Sub setAutoScreen(mode As Boolean)
    End Sub
    Protected Const TYPE_AUTO = 0
    Protected Const TYPE_MANUAL = 1
    Protected AUTO_MANUAL_BTN As String
    ''' <summary>
    ''' 自動ボタン押下処理
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub btnAuto_Click(sender As Object, e As EventArgs) Handles btnAuto.Click
        If chkAuto() = False Then Exit Sub
        PutLog(Me.ToString, "自动状态", "自动状态 按钮按下")
        AUTO_MANUAL_BTN = TYPE_AUTO
        btnTmpChg.Visible = False
        setRackFlowButtonColor(TYPE_AUTO)
        setAutoScreen(True)
        setupAutoInputBase(False)
        Me.panelHeader.BackColor = Color.FromKnownColor(KnownColor.Gold)
        Me.BackColor = Color.FromKnownColor(KnownColor.Gold)
        If m_fIcTagUsed AndAlso Not IsNothing(g_cRFID) Then
            g_cRFID.ClearData()
        End If
        TimerTag.Enabled = False
        TimerTag.Stop()
        m_ProcessStatus = ProcessStatus.TagSet
        'IcTag = New TagData
        'LastTag = New TagData
        initializForm_FLG = False

        'TODO：改造要
        'm_cEquipCommandControl = New clsEquipCooperateCommand(m_EquipIPAddress, m_EquipPort)
        ''m_cEquipCommandControl = New clsEquipCooperateCommand("127.0.0.1", "5300")

        'If m_cEquipCommandControl.IsSetting() Then
        '    If m_cEquipCommandControl.CommandConnect() = False Then

        '        MsgBox(getMsgStr("MSG00186"))
        '    End If
        'End If

    End Sub
    Overridable Sub setinitializForm_FLG()

    End Sub
    Overridable Function chkAuto() As Boolean
        Return True
    End Function
    ''' <summary>
    ''' 手動ボタン押下処理
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub btnManual_Click(sender As Object, e As EventArgs) Handles btnManual.Click
        PutLog(Me.ToString, "手动状态", "手动状态 按钮按下")
        AUTO_MANUAL_BTN = TYPE_MANUAL
        If IcTag.frameIDFlag = True Then
            'btnTmpChg.Visible = True
        Else
            btnTmpChg.Visible = False
        End If
        setRackFlowButtonColor(TYPE_MANUAL)
        setAutoScreen(False)
        setupAutoInputBase(True)
        Command_LD_Received = False
        Me.panelHeader.BackColor = Color.FromKnownColor(KnownColor.Control)
        Me.BackColor = Color.FromKnownColor(KnownColor.Control)
        'IcTag = New frmStartCompleteBase.TagData
        'LastTag = New frmStartCompleteBase.TagData
        If m_fIcTagUsed Then
            m_fIsGettingData = False
            TimerTag.Enabled = True
            TimerTag.Start()
        End If
        initializForm_FLG = True
        'If IsNothing(m_cEquipCommandControl) = False Then
        '    m_cEquipCommandControl.CommandDisConnect()
        'End If
        btnLotTxt.Enabled = True
        btnLotTxt.PerformClick()
    End Sub

    ''' <summary>
    ''' 自動ボタン、手動ボタンの表示モードの変更
    ''' </summary>
    ''' <param name="btnType">表示モード０：自動。１：手動</param>
    Private Sub setRackFlowButtonColor(btnType As Integer)

        If btnType = TYPE_MANUAL Then
            btnManual.BackColor = Color.DodgerBlue
            btnAuto.BackColor = SystemColors.Control
            btnAuto.UseVisualStyleBackColor = True
        Else
            btnAuto.BackColor = Color.DodgerBlue
            btnManual.BackColor = SystemColors.Control
            btnManual.UseVisualStyleBackColor = True
        End If

    End Sub
    ''' <summary>
    ''' ラック流動有効設定を行うため、ステータスチェックを行う
    ''' </summary>
    ''' <returns></returns>
    Protected Overridable Function isStatusCheck() As Boolean
        Return False
    End Function
    Protected Overridable Function isCheckProc() As Boolean
        Return False
    End Function
    ''' <summary>
    ''' DB設定により、ラック流動の有効・無効を設定する
    ''' </summary>
    Public Sub SetRackFlowEnable()

        If m_cEquipMat.GetRackFlowFlag(lblProcessCD.Text) And m_cEquipMat.getSocketFlag(g_CURRENT_EQUIP_ID) = SOCKET_FLAG_ON And isCheckProc() = False Then
            AutoManualMode = 0
            Button2.Enabled = True
            btnLC.Enabled = True
            TimerBegin.Stop()
            'TODO：改造要
            m_cEquipCommandControl = New clsEquipCooperateCommand(m_EquipIPAddress, m_EquipPort)
            'm_cEquipCommandControl = New clsEquipCooperateCommand("127.0.0.1", "5300")
            m_cEquipCommandControl.ParentForm = Me
            If m_cEquipCommandControl.IsSetting() Then
                If m_cEquipCommandControl.CommandConnect() = False Then
                    MsgBox(getMsgStr("MSG00186"))
                End If
            End If

            '    setRackFlowButton(True)
            '    setRackFlowButtonColor(TYPE_AUTO)
            '    SetAutoFlagItem(True)
            '    '共通部設定
            '    setupAutoInputBase(False)
            '    If m_fIcTagUsed Then
            '        TimerTag.Start()
            '    End If
            setRackFlowButton(True)
            btnAuto.PerformClick()
            'btnTmpChg.Visible = True'DEL MIAO 20200907
        Else
            AutoManualMode = 1
            Button2.Enabled = False
            btnLC.Enabled = False
            TimerBegin.Start()
            '    MsgBox("false")
            '    setRackFlowButton(False)
            '    SetAutoFlagItem(False)
            '    setRackFlowButtonColor(TYPE_MANUAL)
            '    '共通部設定
            'setupAutoInputBase(True)
            '    If m_fIcTagUsed Then
            '        TimerTag.Start()
            '    End If
            setRackFlowButton(False)
            btnManual.PerformClick()
            'btnTmpChg.Visible = False 'DEL MIAO 20200907

        End If
    End Sub
    'Public Sub SetAutoFlagItem(flag As Boolean)
    '    If flag Then
    '        setRackFlowButtonColor(TYPE_AUTO)
    '        setAutoScreen(True)
    '        Me.panelHeader.BackColor = Color.FromKnownColor(KnownColor.Gold)
    '        Me.BackColor = Color.FromKnownColor(KnownColor.Gold)

    '        TimerTag.Stop()
    '        m_ProcessStatus = ProcessStatus.TagSet

    '    Else
    '        setRackFlowButtonColor(TYPE_MANUAL)
    '        setAutoScreen(False)
    '        Me.panelHeader.BackColor = Color.FromKnownColor(KnownColor.Control)
    '        Me.BackColor = Color.FromKnownColor(KnownColor.Control)
    '        If m_fIcTagUsed Then
    '            TimerTag.Start()
    '        End If
    '    End If
    '    setRackFlowButton(False)
    'End Sub
    Public Sub setRackFlowButton(enable As Boolean)
        btnAuto.Enabled = enable
        btnManual.Enabled = enable
    End Sub
    Protected Sub HideCommandWaiting()
        Me.Cursor = Cursors.Default
        lblWait.Visible = False
        Me.Enabled = True
    End Sub
    Protected Sub ShowCommandWaiting()
        Me.Cursor = Cursors.WaitCursor
        lblWait.Text = "正在等待MPC命令・・・"
        lblWait.Top = Int((Me.Height - lblWait.Height) / 2)
        lblWait.Left = Int((Me.Width - lblWait.Width) / 2)
        lblWait.BringToFront()
        lblWait.Visible = True
        Me.Enabled = False
        m_cEquipCommandControl.syncTimer.Start()
        'm_cEquipCommandControl.IsOnlineSync = True

    End Sub

    ''' <summary>
    ''' ラックNoからロットNoを検索して返却します。
    ''' </summary>
    ''' <param name="rackNo"></param>
    ''' <returns></returns>
    Public Function getLotNoByRack(ByVal rackNo As String) As String
        Dim lotNo As String = m_cLotDefect.GetLotNoByRack(rackNo)
        Dim dtLot As DataTable
        If inputLotType = INPUTLOTTYPE_ASM Then
            IcTag.szLotNo = lotNo
            SyncLotInfo()
        Else
            dtLot = getLotNoListByRack(rackNo, m_szProc)
            If dtLot.Rows.Count = 0 Then
                lotNo = ""
            End If
            If dtLot.Rows.Count > 0 Then
                lotNo = dtLot(0)(0)
            End If

        End If

        Return lotNo
    End Function

    ''' <summary>
    ''' ウェハーCaseNoからロットNoを検索して返却します。
    ''' </summary>
    ''' <param name="WaferCaseNo"></param>    
    ''' ''' <param name="kouteiCD"></param>
    ''' <returns>ウェハーLotNo下の組立No.（複数）</returns>
    Protected Function getLotNoListByRack(ByVal WaferCaseNo As String, kouteiCD As String) As DataTable
        Dim lotNoData As DataTable = m_cLotDefect.GetLotNoListByRack(WaferCaseNo, m_cIdohyo.ProcCdInfo)
        'If lotNoData.Rows.Count > 0 Then
        '    For i As Integer = 0 To lotNoData.Rows.Count - 1
        '        IcTag.szLotNo = lotNoData.Rows(i)("LOT_NO")
        '        SyncLotInfo()
        '    Next
        'End If
        If lotNoData.Rows.Count = 0 Then
            m_cLotDefect.insertRackInfo(WaferCaseNo)
            lotNoData = m_cLotDefect.GetLotNoListByRack(WaferCaseNo, m_cIdohyo.ProcCdInfo)
        End If
        Return lotNoData
    End Function
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="Groupid">GroupID</param>
    ''' <param name="kouteiCD">工程</param>
    ''' <returns>取得groupID下的最后一个LotNo</returns>
    Protected Function getLastLotNoByGroupID(ByVal Groupid As String, kouteiCD As String) As String
        Return m_cLotDefect.GetLastLotNoByGroupID(Groupid, kouteiCD)
    End Function

    ''' <summary>
    ''' 不良内容更新
    ''' </summary>
    Public Sub setErrorInfoOnlyNG(Optional ByVal receiveData As receiveCommandData = Nothing)
        Dim dt As DataTable
        Dim proccd As String
        proccd = IIf(AProcCD() = "", lblProcessCD.Text, AProcCD)
        PutLog(Me.ToString, "setErrorInfoOnlyNG", "1：" & proccd & "|" & txtLotNo.Text & "|" & lblEquipID.Text)

        dt = m_cLotDefect.GetFrameInfo(proccd, txtLotNo.Text, lblEquipID.Text)
        If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Rows(0)("totalPkgCnt").ToString = "0" Then
            PutLog(Me.ToString, "setErrorInfoOnlyNG", "dt is nothing")

            If IsNothing(receiveData) = False Then
                lblFailedCnt.Text = receiveData.badNum '不良数
            Else
                lblFailedCnt.Text = 0 '不良数
            End If
        Else
            lblCompleteCnt.Text = dt.Rows(0)("totalOkCnt").ToString  '良品数
            PutLog(Me.ToString, "setErrorInfoOnlyNG", "2:" & lblFailedCnt.Text）
            RemoveHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged
            lblFailedCnt.Text = 0

            lblFailedCnt.Text = dt.Rows(0)("totalNGCnt").ToString  '不良数
            PutLog(Me.ToString, "setErrorInfoOnlyNG", "3:" & lblFailedCnt.Text）
            If dgvError.Rows.Count > 0 Then

                Dim errsum As Integer
                For i As Integer = 0 To dgvError.DataSource.Rows.Count - 1
                    Try
                        PutLog(Me.ToString, "setErrorInfoOnlyNG", "dgvError:" & dgvError.DataSource.Rows(i)(3)）
                        errsum = errsum + CInt(dgvError.DataSource.Rows(i)(3))
                    Catch ex As Exception
                        errsum = 0
                    End Try

                Next
                lblFailedCnt.Text = errsum.ToString
            Else
                lblFailedCnt.Text = 0
            End If
            AddHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged
            PutLog(Me.ToString, "setErrorInfoOnlyNG", "4:" & lblFailedCnt.Text）

            lblPcbCnt.Text = dt.Rows(0)("frameCnt").ToString
            lblCrossCnt.Text = dt.Rows(0)("totalCrossCnt").ToString
            lblCrossPcbCnt.Text = dt.Rows(0)("crossPcbCnt").ToString
            If Not IsNothing(lblEmptyChipsCnt) Then
                PutLog(Me.ToString, "EmptyChipsCnt", "lblEmptyChipsCnt:" & lblEmptyChipsCnt.Text）

                lblEmptyChipsCnt.Text = dt.Rows(0)("totalEmptyCnt").ToString '空チップ数 
            End If
            PutLog(Me.ToString, "setErrorInfoOnlyNG", "5:" & lblPcbCnt.Text & "|" & lblCrossCnt.Text & "|" & lblCrossPcbCnt.Text）

        End If
        Me.Refresh()
        setXInnNum()
    End Sub
    '''' <summary>
    '''' 不良内容更新
    '''' </summary>
    'Public Sub setErrorInfo(Optional ByVal receiveData As receiveCommandData = Nothing)
    '    Dim dt As DataTable
    '    Dim proccd As String
    '    proccd = IIf(AProcCD() = "", lblProcessCD.Text, AProcCD)
    '    dt = m_cLotDefect.GetFrameInfo(proccd, txtLotNo.Text, lblEquipID.Text)
    '    If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Rows(0)("totalPkgCnt").ToString = "0" Then

    '        If IsNothing(receiveData) = False Then
    '            lblCompleteCnt.Text = receiveData.compNum '良品数
    '            lblFailedCnt.Text = receiveData.badNum '不良数
    '            lblPcbCnt.Text = receiveData.frameNum 'フレーム数
    '            lblCrossCnt.Text = 0 'X印数
    '            lblCrossPcbCnt.Text = 0 'X印枚数
    '        Else

    '        End If

    '    Else
    '        lblCompleteCnt.Text = dt.Rows(0)("totalOkCnt").ToString  '良品数
    '        If isRackNoFlow() = True Then
    '            lblCompleteCnt.Text = CInt(dt.Rows(0)("totalOkCnt").ToString) + CInt(dt.Rows(0)("totalEmptyCnt").ToString) '良品数
    '        End If
    '        RemoveHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged
    '        lblFailedCnt.Text = dt.Rows(0)("totalNGCnt").ToString  '不良数
    '        If dgvError.Rows.Count > 0 Then
    '            Dim errsum As Integer
    '            For i As Integer = 0 To dgvError.DataSource.Rows.Count - 1
    '                Try
    '                    errsum = errsum + CInt(dgvError.DataSource.Rows(i)(3))
    '                Catch ex As Exception
    '                    errsum = 0
    '                End Try

    '            Next
    '            lblFailedCnt.Text = errsum.ToString
    '        End If
    '        AddHandler lblFailedCnt.TextChanged, AddressOf lblFailedCnt_TextChanged

    '        lblPcbCnt.Text = dt.Rows(0)("frameCnt").ToString       'フレーム数
    '        lblCrossCnt.Text = dt.Rows(0)("totalCrossCnt").ToString
    '        lblCrossPcbCnt.Text = dt.Rows(0)("crossPcbCnt").ToString

    '        If Not IsNothing(lblEmptyChipsCnt) Then
    '            lblEmptyChipsCnt.Text = dt.Rows(0)("totalEmptyCnt").ToString '空チップ数 
    '        End If

    '    End If
    '    Me.Refresh()
    'End Sub

    ''' <summary>
    ''' 共通部：自動・手動時の入力項目設定
    ''' </summary>
    ''' <param name="Input">True：入力可</param>
    Public Sub setupAutoInputBase(Input As Boolean)
        'ロットNo
        btnLotTxt.Enabled = Input
        btnDiffLot.Enabled = Input
        txtLotNo.Visible = Input
        txtDiffLot.Visible = Input
        'フレーム数
        lblPcbCnt.Enabled = Input
        lblPcbCnt.DefaultColor = setInputTenkeyColor(Input)
        'X印数
        lblCrossCnt.Enabled = Input
        lblCrossCnt.DefaultColor = setInputTenkeyColor(Input)
        'X印枚数
        lblCrossPcbCnt.Enabled = Input
        lblCrossPcbCnt.DefaultColor = setInputTenkeyColor(Input)

        If Input Then
            btnLot_Enable()
        End If
    End Sub
    Public Function setInputTenkeyColor(Input As Boolean) As Color
        Return IIf(Input, TENKEY_INIT_COLOR, NORMAL_INIT_COLOR)
    End Function
    Public Function setInputBarcodeColor(Input As Boolean) As Color
        Return IIf(Input, BARCODE_INIT_COLOR, NORMAL_INIT_COLOR)
    End Function
    ''' <summary>
    ''' 工程スキップ
    ''' </summary>
    ''' <param name="LotNo">LotNo</param>
    ''' <param name="Employee">作業者</param>
    Protected Sub ProcSkip(LotNo As String, Employee As String)
        Dim inputBsite As New InSiteWebService.InOperationSkip
        Dim outputBsite As New InSiteWebService.OutOperationSkip
        inputBsite.Employee = Employee  '開始作業者
        inputBsite.Lot = LotNo          'ロットNo
        inputBsite.IgnoreMesurementFlag = True
        Dim clientProcCd = GetBsiteClientString()

        outputBsite = OperationSkipService_Execute(inputBsite, clientProcCd)
        '戻り情報を保持
        outHeader = outputBsite.Header
        MsgBox(outHeader.Status)

    End Sub

    Private Sub btnCheckInfoClose_Click(sender As Object, e As EventArgs) Handles btnCheckInfoClose.Click
        txtChkInfo.Text = ""
        pnlCheckInfo.Visible = False
        clsInfoAfter()
    End Sub
    Overridable Sub clsInfoAfter()

    End Sub

    'UPD MIAO 20200907 BEGIN
    Private Sub btnTmpChg_Click(sender As Object, e As EventArgs) Handles btnTmpChg.Click

        If IcTag.iFrameIDUse = 0 Then Exit Sub

        If MsgBox(getMsgStr("MSG00117", "确定要" & btnTmpChg.Text & "吗？"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            IcTag.iFrameIDUse = 0
            m_cEquipMat.setFrameIDUse(IcTag.szLotNo, IcTag.iFrameIDUse)
            btnTmpChg.Visible = False

        End If
    End Sub
    'UPD END

    Private Sub btnLC_Click(sender As Object, e As EventArgs) Handles btnLC.Click
        PutLog(Me.ToString, "再次照合", "点击再次照合按钮。")
        If LC_COMMAND <> "" Then
            PutLog(Me.ToString, "再次照合：sendCommand", LC_COMMAND)
            m_cEquipCommandControl.CommandSend(LC_COMMAND)
            Command_LD_Received = False
            ShowCommandWaiting()
        Else
            If txtLotNo.Text <> "" Then
                doLC()
                'Dim tmpLotNo As String = txtLotNo.Text
                'Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)
                'Dim pkgValue As String = getLCPackage()
                'If m_EquipInstPattern <> "00" Then
                '    If pkgValue = "too Much" Then
                '        setCheckInfo("程序被设定多条，请确认。")
                '        Exit Sub
                '    End If
                '    If pkgValue = "" Then
                '        setCheckInfo("没有设定程序，请确认。")
                '        Exit Sub
                '    End If
                'End If
                'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "", lblInputFrm.Text, pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
                'Command_LD_Received = False
                'ShowCommandWaiting()
            End If
        End If
    End Sub

    Public Function getWithLotResinProdName(lotno As String, prodName As String, ByRef newLotno As String) As String

        Dim Resin As String = ""
        Dim rtn As String = ""
        newLotno = lotno
        Dim PrevLot As String = ""

        'MAKE工程 特别处理（半完品出库后，便是MAKE，半完品出库前和出库后lotNo不一样）
        If lblProcessCD.Text = "A54" Then

            PrevLot = getPrevLot(lotno)
            'lot的树脂信息
            Resin = m_cData.GetResin(lotno)
            '如果lot的树脂信息为空，便去找母lot的树脂
            If Resin = "" Then
                If PrevLot <> "" Then
                    Resin = m_cData.GetResin(PrevLot)
                End If
            End If

            Dim newResin As String = Resin
            '如不足8位，不足部分用X补足8位
            For i As Integer = Resin.Length To 7
                newResin = newResin & "X"
            Next
            rtn = writeCommandData(prodName, IDENTIFIER_NAME_MARK)
            rtn = rtn.Substring(1, rtn.Length - 1) + newResin

            '如果存在母lot，并且母lot和新lot不一致，则把母lot放到新lot后面，各15位
            If PrevLot <> "" And PrevLot <> lotno Then
                newLotno = writeCommandData(lotno, IDENTIFIER_LOTNO_MARK)
                newLotno = newLotno.Substring(1, newLotno.Length - 1) + PrevLot
            End If

        End If

        Return rtn
    End Function
    Protected Function getPrevLot(childLotNo As String) As String

        'ViewLotService情報取得-
        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = childLotNo
        Dim clientStr As String = GetBsiteClientString()
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        outLotInfo = viewLotServiceInfo.LotInf

        Return outLotInfo.PrevLot

    End Function

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
        Dim loginUser As New clsLoginUser
        Dim EQUIP As String

        If txtUser.Text.Trim = "" Then

            MsgBox(getMsgStr("MSG00002", lblUser.Text))
            txtUser.Focus()
            Exit Sub
        End If

        '設備Noをiniファイルから取得
        EQUIP = GetIniFile("EQUIP", "EquipID", "", g_szInitFileName)
        'スキャンしたUserNoをDBにInsert or Update
        loginUser.insUser(EQUIP, txtUser.Text)

        '----------2021 DC、TC、LTF自动着工对应0619 begin
        If CUSTOMIZES_DC_TC_LTF_AUTO = True And AutoManualMode = 0 Then
            Dim WF_command As String = "WFM02C00ROKT00M" & txtUser.Text.PadRight(60, " ")
            m_cEquipCommandControl.CommandSend(WF_command)
        End If
        '----------2021 DC、TC、LTF自动着工对应0619 end
        'setPLT_FLAG()
        UserNo = txtUser.Text
        txtUser.Text = ""
        Time_LoginUser.Start()
        pnlUserLogin.Visible = False

        If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Processing Then
            txtOptNoEnd.Text = userNo
            Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
            txtOptNoEnd_KeyPress(txtOptNoStt, a)
        End If
        If Not IsNothing(IcTag.szLotNo) AndAlso IcTag.Status = TagProcessStatus.Ready Then
            txtOptNoEnd.Text = userNo
            txtOptNoStt.Text = txtOptNoEnd.Text
            Dim a As KeyPressEventArgs = New KeyPressEventArgs(vbCr)
            txtOptNoStt_KeyPress(txtOptNoStt, a)
        End If
    End Sub

    Private Sub btnUserExit_Click(sender As Object, e As EventArgs) Handles btnUserExit.Click

        txtUser.Text = ""
        Time_LoginUser.Start()
        pnlUserLogin.Visible = False

    End Sub
    Protected Function getUdf11(szLotNo As String) As String

        'ViewLotService情報取得-
        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = szLotNo
        Dim clientStr As String = GetBsiteClientString()
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        outLotInfo = viewLotServiceInfo.LotInf

        Return outLotInfo.Udf11

    End Function
    Protected Function getBsitePrcdCD(childLotNo As String) As String

        'ViewLotService情報取得-
        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = childLotNo
        Dim clientStr As String = GetBsiteClientString()
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        outLotInfo = viewLotServiceInfo.LotInf

        Return outLotInfo.Operation

    End Function

    Protected Overridable Function getProcessingLot() As String

        Dim mOutParam As New InSiteWebService.OutViewMachine
        Dim InHeader As New InSiteWebService.InHeader
        Dim rtnlot As String = ""
        Dim zb1Lot As String = ""
        Dim clientStr As String = GetBsiteClientString()
        ShowBsiteWaiting()
        mOutParam = ViewMachineService_GetInf(lblEquipID.Text, clientStr) '装置検索
        HideCommandWaiting()
        If IsNothing(mOutParam.MachineInf.InProcLotInf) OrElse mOutParam.MachineInf.InProcLotInf.Count = 0 Then
            rtnlot = ""
        Else
            For i As Integer = 0 To mOutParam.MachineInf.InProcLotInf.Length - 1
                Dim dt1 As DataTable = m_cData.GetWbLotData(mOutParam.MachineInf.InProcLotInf(i).Lot)
                If dt1.Rows.Count > 0 Then
                    If dt1.Rows(0)("KOUTEI_CODE") = "S42" Or   'DB
                       dt1.Rows(0)("KOUTEI_CODE") = "A10" Or   'TC
                       dt1.Rows(0)("KOUTEI_CODE") = "A53" Then 'LTF

                        rtnlot = mOutParam.MachineInf.InProcLotInf(i).Lot
                        '判断是否是2厂的产品，1厂的产品不进行处理
                        If isZB1(rtnlot) Then
                            zb1Lot = rtnlot
                            Exit For
                        End If
                    End If
                End If
            Next

        End If

        Return zb1Lot

    End Function

    Private Function isZB1(lotNo As String)

        Dim m_cEquipMat As New clsDbEquipMat
        Dim m_cLotInfo As New clsDbLotInfo
        Dim rtn As Boolean = True

        Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
        param.Name = lotNo
        Dim clientStr As String = m_cEquipMat.GetBsiteClientString(lblProcessCD.Text)
        Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
        If Not IsNothing(viewLotServiceInfo) AndAlso STS_SUCCESS.Equals(viewLotServiceInfo.Header.Status) Then
            If viewLotServiceInfo.LotInf.Udf2 = "ZB1" Then
                rtn = True
            End If
        End If
        Return rtn
    End Function

    Private Sub frmStartCompleteBase_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
        PutLog(Me.ToString, "CLOSE", "COLSE FORM")
    End Sub

    Private Sub doLC()
        Dim tmpLotNo As String = txtLotNo.Text
        Dim strkindNm As String = getWithLotResinProdName(txtLotNo.Text, lblkindNm.Text, tmpLotNo)
        Dim pkgValue As String = getLCPackage()
        If m_EquipInstPattern <> "00" Then
            If pkgValue = "too Much" Then
                setCheckInfo("程序被设定多条，请确认。")
                Exit Sub
            End If
            If pkgValue = "" Then
                setCheckInfo("没有设定程序，请确认。")
                Exit Sub
            End If
        End If
        Dim strShape As String = getShape()
        If strShape = "" Then strShape = pkgValue
        sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, strkindNm, txtOptNoStt.Text, tmpLotNo, lblInputCnt.Text, "",
                      lcFrmNum(), pkgValue, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text, strShape)
        Command_LD_Received = False
        ShowCommandWaiting()
    End Sub

    Protected Overridable Function getShape() As String
        Return ""
    End Function

    Protected Overridable Function lcFrmNum() As String
        Return lblInputFrm.Text
    End Function

#End Region
End Class
